Unable to execute powershell command remotely "Error HRESULT E_FAIL has been returned from a call to a COM component"

MK-2951 26 Reputation points
2020-12-26T11:38:41.35+00:00

Hello to all,

I am trying to execute this command remotely as a Admin01 user account:

Invoke-Command -ComputerName PC01 -ScriptBlock {
$UI = New-Object -ComObject "UIResource.UIResourceMgr"
$ProgramID = "*"
$PackageID = "PKG001"
$UI.ExecuteProgram($ProgramID, $PackageID, $true)
}

Error HRESULT E_FAIL has been returned from a call to a COM component.

  • CategoryInfo : OperationStopped: (:) [], COMException
  • FullyQualifiedErrorId : System.Runtime.InteropServices.COMException
  • PSComputerName : PC01

It works fine if the user Admin01 is logged in on that PC01. Can someone help to figured out this? The aim is to execute Task Sequence on multiple computers via Powershell script.

Thanks.

M.

Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,359 questions
Microsoft Configuration Manager
{count} votes

2 answers

Sort by: Most helpful
  1. Raymond Zayas 1 Reputation point
    2022-05-03T13:54:33.997+00:00

    Did RichMatheisen-8856's solution work for you?

    I'm facing the same issue.

    Thanks for the help.

    0 comments No comments

  2. GLAA-0972 0 Reputation points
    2023-02-02T15:15:54.67+00:00

    Only the first User Session can execute .
    make shure, all other users are logged off

    0 comments No comments