Skip to content

Instantly share code, notes, and snippets.

@sheepla
Last active December 25, 2022 09:47
Show Gist options
  • Select an option

  • Save sheepla/ea46c645aba7885d2cdc838cf1f3cad2 to your computer and use it in GitHub Desktop.

Select an option

Save sheepla/ea46c645aba7885d2cdc838cf1f3cad2 to your computer and use it in GitHub Desktop.
Get COM class name and CLSID with Powershell
<#
.DESCRIPTION
Get available COM (Component Object Model) class name and CLSID
.SYNOPSIS
Get-ComClassNameAndClsid.ps1 [-ClassName] ClassName
.EXAMPLE
Get-ComClassNameAndClsid.ps1 internetexplorer
# or...
"internetexplorer" | Get-ComClassNameAndClsid.ps1
CLSID Name
----- ----
{0002DF01-0000-0000-C000-000000000046} InternetExplorer.Application.1
#>
param(
[Parameter(
Mandatory=$true,
ValueFromPipeline=$true,
ValueFromPipelineByPropertyName=$true,
Position=1)]
[Alias("Name")]
[string] $ClassName
)
Get-ChildItem -Include "PROGID" -Recurse REGISTRY::HKEY_CLASSES_ROOT\CLSID | %{
[pscustomobject] @{
CLSID = [System.IO.Path]::GetFileName([System.IO.Path]::GetDirectoryName($_.Name))
ClassName = $_.GetValue("");
}
} | ? { $_.ClassName -IMatch $ClassName }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment