Task Sequence - HRESULT E_Fail has been returned from a call to a COM Component

Hi. I’m running a task sequence using the Toolkit with the commands below. When I run Deploy-Application.exe on the computer it runs ok. When I run the command using SCCM I get the error

Error HRESULT E_Fail has been returned from a call to a COM Component. Exact error attached.

$TSName = “Windows10-Upgrade-1809-v2.0”
$trigger = “{00000000-0000-0000-0000-000000000021}”
$machine = $env:COMPUTERNAME
$SoftwareCenter = New-Object -ComObject “UIResource.UIResourceMgr”
$TS = SoftwareCenter.GetAvailableApplications() | ?{.PackageName -eq “$TSName”}
Invoke-WmiMethod -Namespace root\ccm -Class sms_client -Name TriggerSchedule $trigger
$TS = SoftwareCenter.GetAvailableApplications() | ?{
.PackageName -eq “$TSName”}

Any Idea’s ?

My Package Program is set to run as Administrator & “Allow users to Interact with program”

It looks like it fails because the method ExecuteProgram returns E_FAIL, it could be a parameter which is faulty or maybe the order of the parameters is wrong.

Personally i wouldnt mix COM and WMI unless i have to, from what i have gathered COM-objects needs to be cleaned up once they are not needed to prevent a tainted environment.

This will show your TS if the client knows about it:

Get-CimInstance -ClassName 'CCM_Program' -Namespace root\ccm\clientsdk

And using the class CCM_ProgramManager you can invoke the TS using the method ExecutePrograms. Both the ProgramID and PackageID which are the parameters for this method should be found in the class CCM_Program.

I hope this helps!