List COM Objects


in old post ( http://www.vistax64.com/powershell/91583-there-any-script-get-list-com-objects-computer.html ) i've found solution list every com objects in computer

these 2 solutions posted:

1) gci hklm:\software\classes -ea 0| ? {$_.pschildname -match '^\w+\.\w+$' -and (gp "$($_.pspath)\clsid" -ea 0)} | ft pschildname

, simpler one:

2) get-wmiobject win32_comclass

first 1 great because returns pschildname can use in  $xl = new-object -comobject <pschildname>

second 1 shorter, , 1 use, far cannot find pschildname in form xxxxxxx.yyyyyyy $xl = new-object -comobject excel.application

thoughts ?





hi cyreli,

the first command doesn't return every com class, those where progid matches pattern of <letters>.<letters>.

the win32_comclass doesn't directly contain progid of of classes, time cross reference with the values contained within win32_classiccomclasssetting wind extremely slow executing query.

what place function such 1 detailed james brundage here( http://blogs.msdn.com/b/powershell/archive/2009/03/20/get-progid.aspx) into powershell profile it's availible.  execution time is fine , takes 64-bit computing account (which nice...)

  function get-progid {                #.synopsis          #  gets of progids registered on system          #.description          #  gets progids registered on system. progids returned can used new-object -comobject          #.example          #  get-progid          #.example          #  get-progid | where-object { $_.progid -like "*image*" }           param()          $paths = @("registry::hkey_classes_root\clsid")          if ($env:processor_architecture -eq "amd64") {            $paths+="registry::hkey_classes_root\wow6432node\clsid"          }           get-childitem $paths -include versionindependentprogid -recurse |          select-object @{            name='progid'            expression={$_.getvalue("")}              }, @{            name='32bit'            expression={              if ($env:processor_architecture -eq "amd64") {                $_.pspath.contains("wow6432node")                } else {                $true              }                  }          }        }  

if haven't done already, below 2 lines create profile you..

  new-item ($profile -replace "\\[^\\]*ps1$") -itemtype directory  notepad $profile  

 then paste in function definition profile, restart powershell , voila, done.

you of course exact same thing code source article (as note, if do, i'd replace call format-table @ end select.  way can send results of function off down pipeline without many problems, formatting cmdlets should @ end of pipeline).

hope helps,

matthew



Windows Server  >  Windows PowerShell



Comments

Popular posts from this blog

Motherboard replacement

Cannot create Full Text Search catalog after upgrading to V12 - Database is not fully started up or it is not in an ONLINE state

Remote Desktop App - Error 0x207 or 0x607