Skip to content

Instantly share code, notes, and snippets.

@exorcistas
Created April 23, 2022 19:46
Show Gist options
  • Save exorcistas/f78f3896bfa0aac737dfc79401034d39 to your computer and use it in GitHub Desktop.
Save exorcistas/f78f3896bfa0aac737dfc79401034d39 to your computer and use it in GitHub Desktop.
Powershell function to get selected COM object attributes
function Get-ComObject {
param(
[Parameter(Mandatory=$true,
ParameterSetName='FilterByName')]
[string]$Filter,
[Parameter(Mandatory=$true,
ParameterSetName='ListAllComObjects')]
[switch]$ListAll
)
$ListofObjects = Get-ChildItem HKLM:\Software\Classes -ErrorAction SilentlyContinue | Where-Object {
$_.PSChildName -match '^\w+\.\w+$' -and (Test-Path -Path "$($_.PSPath)\CLSID")
} | Select-Object -ExpandProperty PSChildName
if ($Filter) {
$ListofObjects | Where-Object {$_ -like $Filter}
} else {
$ListofObjects
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment