All COM objects possible with New-object -COMOBJECT parameter

Welcome Forums General PowerShell Q&A All COM objects possible with New-object -COMOBJECT parameter

This topic contains 5 replies, has 4 voices, and was last updated by

 
Participant
1 month, 2 weeks ago.

  • Author
    Posts
  • #119497

    Participant
    Points: 180
    Rank: Participant

    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.

     

  • #119542

    Participant
    Points: 866
    Helping Hand
    Rank: Major Contributor

    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.

  • #119557

    Participant
    Points: 34
    Rank: Member

    In the past I have used the OLE_COM Object explorer.. I think this is the link https://msdn.microsoft.com/en-us/library/d0kh9f4c.aspx

     

    • #119563

      Participant
      Points: 180
      Rank: Participant

      Many thanks, Mr Simon B, this is useful as a starting point ... much appreciated.

  • #119519

    Participant
    Points: 9
    Rank: Member

    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)"
    }
    }

     

    • #119598

      Participant
      Points: 180
      Rank: Participant

      Hello Neemobeer,

      Your script has saved me many man hours of guesswork.

      Much appreciated, my sincerest thanks.

       

You must be logged in to reply to this topic.