Public/Get-ComProgId.ps1

<#
 
# Get-ComProgId
 
Diese ProgId kann u.a. für New-Object -COMObject ... benutzt werden um COM-Objekte zu erzeugen.
 
- **Hashtags** UserCmdlet WM I COMObject
- **Version** 2019.01.01
 
#>


using namespace System
using namespace System.Runtime.InteropServices
$ErrorActionPreference = [System.Management.Automation.ActionPreference]::Stop
Set-StrictMode -Version Latest

function Get-ComProgId { 
    <#
        .Synopsis
            Ermittelt die ProgIDs aller registrierter COM-Objekte auf dem aktuellen System.
     
        .Description
            Diese ProgId kann u.a. für New-Object -COMObject ... benutzt werden um
            COM-Objekte zu erzeugen.
     
        .Example
            Get-ProgID
     
        .Example
            Get-ProgID | ? ProgID -match "excel"
    #>
          
    param(
    )            
    
    $paths = @("REGISTRY::HKEY_CLASSES_ROOT\CLSID")            
    if ($env:Processor_Architecture -eq "amd64") {            
        $paths += "REGISTRY::HKEY_CLASSES_ROOT\Wow6432Node\CLSID"            
    }
                 
    Get-ChildItem -Path $paths -include VersionIndependentPROGID -Recurse | ForEach-Object {
        if ($env:Processor_Architecture -ne "AMD64" -or $_.PSPath.Contains("Wow6432Node")) {
            $ProcessorArchitecture = "x86"
        } else {
            $ProcessorArchitecture = "Amd64"
        } 
        [PSCustomObject]@{
            GUID                  = (Split-Path -Path $_.PSParentPath -Leaf).Replace("{", "").Replace("}", "")
            ProgID                = $_.GetValue("")
            ProcessorArchitecture = $ProcessorArchitecture
        }
    }
}