-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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