Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Nevember/d00b16a76cdd43f495f75dd33ecfd969 to your computer and use it in GitHub Desktop.
Save Nevember/d00b16a76cdd43f495f75dd33ecfd969 to your computer and use it in GitHub Desktop.
Look up information for multiple CLSIDs; pipeline input is a work-in-progress
Function Get-Clsid {
[CmdletBinding()]
param (
[Parameter (Mandatory=$true,Position=0,ValueFromPipeline=$true)]
[Array]$CLSID
)
$CLSID_KEY = "HKLM:\SOFTWARE\Classes\CLSID"
$ErrorActionPreference = 'SilentlyContinue'
ForEach ($C in $CLSID) {
If (($C -like "{*}") -or ($C -notlike "*`-*`-*`-*`-*")) {
$Path = "$CLSID_KEY\$C"
} Else {
$Path = "$CLSID_KEY\`{$C`}"
}
If (Test-Path $Path) {
$Name = (Get-ItemProperty -Path $Path).'(default)'
$DLL = (Get-ItemProperty -Path "$Path\InProcServer32").'(default)'
If ($null -eq $Name) {
$Name = "Class name not found."
}
If ($null -eq $DLL) {
$DLL = "DLL info not found."
}
$C,$Name,$DLL,''
} Else {
"No results found for query: $C`r`n"
}
}
}
@Nevember
Copy link
Author

Nevember commented Jun 6, 2021

Summary of changes from the original Gist:
• Renamed to use one of the "approved" verbs, "get"
• Script now allows for multiple CLSIDs
• For typical CLSIDs, script will search both with and without brackets '{}'
• Allows for the existence of atypical values within the CLSID key
• Attempts to account for $false/$null results

ToDo:
• ValueFromPipeline currently only returns results from the last item in the array under some circumstances
• May change line 12 to use regex

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment