Script to Find ConfigMgr GUIDs
<# Written by Ryan Ephgrave This script puts a right click menu on everything in ConfigMgr. It is used to find the GUID of a right click menu for menu creation. #> $ConfigInstallPath = $env:SMS_ADMIN_UI_PATH | Out-String $ConfigInstallPath = $ConfigInstallPath.Trim() $XMLPath = $ConfigInstallPath -replace "\\bin\\i386", "\XmlStorage\ConsoleRoot" $ActionsPath = $ConfigInstallPath -replace "\\bin\\i386", "\XmlStorage\Extensions\Actions" Get-ChildItem "$XMLPath" -Filter "*.xml" -Recurse | ForEach-Object { $FullFileName = $_.FullName $FileContent = Get-Content $FullFileName foreach ($line in $FileContent) { if ($line.ToUpper().Contains("NAMESPACEGUID=")) { $SplitLine = $line.Split("`"") $GUID = $SplitLine[1] $FilePath = "$ActionsPath\$GUID" New-Item -ItemType Directory -Path $FilePath -ErrorAction SilentlyContinue | Out-Null $strOutput = "<ActionDescription Class=`"Executable`" DisplayName=`"$GUID`" MnemonicDisplayName=`"$GUID`" Description=`"$GUID`">`n" $strOutput = $strOutput + "<ShowOn><string>ContextMenu</string></ShowOn>`n" $strOutput = $strOutput + "<Executable><FilePath>cmd.exe</FilePath>`n" $strOutput = $strOutput + "<Parameters> /c Powershell.exe Add-Type -AssemblyName 'System.Windows.Forms';[Windows.Forms.Clipboard]::SetText('$GUID')</Parameters></Executable>`n" $strOutput = $strOutput + "</ActionDescription>" $strOutput > "$FilePath\File.xml" } } }
At the MNSCUG meeting I showed a script I use to find the GUIDs to build right click tools. I know there are others out there, but I use my own because I added a feature to copy the GUID to your clipboard when you click on it. This lets you just paste it into a text document so you don’t have to write it down.
Leave a Comment