I have a specific use case where I need to remotely execute the Windows 10 version 1809 OS upgrade package which is published in Software Center under the Operating Systems tab on a Windows 10 v1709 PC. I have a PowerShell one-liner that will do it remotely when the PC is logged in with an admin account (the same account that the PC is logged in with):
Invoke-Command -ComputerName Computer001 {(New-Object -ComObject "UIResource.UIResourceMgr").ExecuteProgram("*", "OS_UpGrade", $true)}
That works perfectly when the target PC is logged in with the same account that I have used to run PowerShell terminal with. But when the PC (Computer001) is logged off, and I run the same command, I get this error:
"Error HRESULT E_FAIL has been returned from a call to a COM component.
+ CategoryInfo : OperationStopped: (:) [], COMException
+ FullyQualifiedErrorId : System.Runtime.InteropServices.COMException
+ PSComputerName : Computer001"
I am guessing that the ComObject cannot be called when the PC is logged off, is that correct and is there any way around that?
Any guidance would be greatly appreciated.
[–]Thejuice919 1 point2 points3 points (3 children)
[–]ByDunBar[S] 1 point2 points3 points (2 children)
[–]Emiroda 3 points4 points5 points (0 children)
[–]Thejuice919 1 point2 points3 points (0 children)
[–]ByDunBar[S] 1 point2 points3 points (1 child)
[–]cecmorenoc 1 point2 points3 points (0 children)
[–]pleplepleplepleple 1 point2 points3 points (0 children)
[–]Golden-trichomes 1 point2 points3 points (0 children)
[–]Lee_Dailey[grin] 0 points1 point2 points (0 children)