[SOLVED] COM Object fails on 64-bit host

by DexterPOSH at 2012-12-19 03:49:35

Hi Power Users,

In order to do some automation related to SCCM Client. I am trying to create a COM Object in a 64-bit PowerShell host as below
$appletmgr = New-Object -ComObject 'CpApplet.CpAppletMgr’
But following error is being thrown.
New-Object : Retrieving the COM class factory for component with CLSID {096C5BA8-044B-4BAC-9914-144723BA4F2A} failed du
e to the following error: 80040154.
At line:1 char:25
+ $client = New-Object <<<< -ComObject ‘CpApplet.CpAppletMgr’
+ CategoryInfo : ResourceUnavailable: (:slight_smile: [New-Object], COMException
+ FullyQualifiedErrorId : NoCOMClassIdentified,Microsoft.PowerShell.Commands.NewObjectCommand

When I create the same object in 32-bit host. It works as expected.
Is there any way I can make this work ? like loading an assembly or do I need to use the 32-bit PowerShell host only.

Thanks for your time.

by nohandle at 2012-12-19 07:10:09
this article describes the same error on 64bit host. It looks like 32bit is your only option.
Btw the COM object can behave differently when called in STA (single threading- like from ISE or remote session) or in MTA mode (locally from console host).