Where can I find all of the COM objects that can be created in PowerShell?
Asked Answered
A

3

47

COM objects can be created and used in PowerShell, 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?

Atchley answered 18/3, 2009 at 22:15 Comment(0)
Q
76

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
Quattrocento answered 18/3, 2009 at 22:37 Comment(7)
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. :)Hungary
my two cents: HKLM\Software\Classesactually corresponds to HKCRForeclosure
And my two cents: rather than piping to ft PSChildName, pipe to select -ExpandProperty PSChildName. That returns the results as an array that can be filtered with -match or Select-String.Foothill
this script above did not work for me, instead this script works: powershellmagazine.com/2013/06/27/…Spermatium
wben you do Format-Text, you will not get strings, but some formatting related classesApiece
@Jeff Can you explain purpose of this filter $_.PSChildName -match '^\w+\.\w+$'Echolalia
Perfectly works in Windows 11 v23H2.Ronironica
F
9

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".

Funerary answered 19/3, 2009 at 6:12 Comment(1)
github.com/tyranid/oleviewdotnetAretta
W
7

Another option that should be noted is through WMI:

Get-WMIObject Win32_ClassicCOMClassSetting
Wellfavored answered 24/3, 2009 at 21:56 Comment(4)
running this produced an infinite loopCaressive
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.Wellfavored
That does not list the ActiveX control I am looking for. This does gist.github.com/810398Zillion
ActiveX Controls won't always have a progid, or more correctly, a programmatic identifier (which is what the scripts above are discovering in HKCR. But they always have a CLSID. If you are just trying to determine whether the ActiveX Control is installed so you can uninstall it, search for its CLSID in HKCR/CLSID.Grubbs

© 2022 - 2024 — McMap. All rights reserved.