I’ve been using New-object in conjunction with EXCEL and ACCESS, e.g.,
New-object -COM ADODB.Connection
New-object -COM ADODB.Recordset
New-object -COM EXCEL.Application
Is there a listing somewhere (not including .NET objects) of all (or the most common) values of objects that can be used with -COM parameter of New-object? Perhaps I am not asking the question properly, but I am a beginner to PS, and would appreciate any advice, tips or references to the appropriate source of information.
Thanking you in advance.
You’ll want to look in the registry under HKCR:\CLSID
Then look under each GUID. Generally if there is a subkey VersionIndependentProgID the default value under this key can potentially be a callable COM object.
New-PSDrive -Name HKCR -Root HKCR -PSProvider Registry
$RootPath = "HKCR:\CLSID"
$CLSIDs = Get-ChildItem $RootPath
Foreach($CLSID in $CLSIDs)
{
$GUID = Split-Path -Leaf $CLSID.Name
$CLSIDPath = "$RootPath\$GUID\VersionIndependentProgID"
If(Test-Path $CLSIDPath)
{
Write-Host $CLSIDPath
Get-ItemProperty -Path $CLSIDPath -Name "(Default)" | Select "(Default)"
}
}
I don’t think there is any documentation out there with the list. I always just do trial and error method if there are no documentations.
In the past I have used the OLE_COM Object explorer… I think this is the link | Microsoft Docs
Many thanks, Mr Simon B, this is useful as a starting point … much appreciated.
Hello Neemobeer,
Your script has saved me many man hours of guesswork.
Much appreciated, my sincerest thanks.