tags:

views:

642

answers:

3

In Powershell I can create COM objects which can be used, for example, to control Microsoft Office applications:

$excel = New-Object -com "Excel.Application"
$excel.visible = $true

How can I list all of the available COM objects that can be created in Powershell?

+6  A: 

I found this powershell one-liner script that supposedly lists all COM objects.

gci HKLM:\Software\Classes -ea 0| ? {$_.PSChildName -match '^\w+\.\w+$' -and
(gp "$($_.PSPath)\CLSID" -ea 0)} | ft PSChildName

let us know if it works!

Jeff Atwood
I can confirm that it does list all the registered COM objects. Whether or not they implement the COM interface correctly is a whole different issue. :)
EBGreen
A: 

Use OleView.exe from Microsoft. I think it may come with Visual Studio. If not, you can find it in the Windows SDK. That's a big download; you can either download the whole thing or you could experiment with downloading it piecemeal using the setup.exe installer.

Once in OleView, look under "type libraries". Excel for instance appears under "Microsoft Exel".

dangph
A: 

Another option that should be noted is through WMI:

Get-WMIObject Win32_ClassicCOMClassSetting
JasonMArcher
running this produced an infinite loop
Dennis Palmer
Since it isn't a loop, it can not possibly be an infinite loop. It will take a long time to run because there are MANY COM components.
JasonMArcher