Lately i’ve been doing lots of powershell “integration” with the SCCM 2012 console (and i’ll continue), but you may be wondering, where do I get the SCCM 2012 console.
Well, i’ve been using a tool called AdminUI.ConsoleBuilder.exe that you find under <CM12ConsoleInstallationPath>\bin and even it is a nice to tool to know about, it unfortunately did not gave me all ID’s i wanted.
Based on this i asked to other MVP’s and Microsoft Project Group and Kaido helped me with his script that you can find here.
This script gave me an idea of what to look for and after a while,but his script did not work with few id’s where the XML file was created only with DefaultHomeTabContextMenu ContextMenuDefaultHomeTab and nothing else.
well, based on this, i’ve created a new script (below is the code) that will create a folder under <CM12ConsoleInstallationPath>\XmlStorage\Extensions\Actions with the NamespaceID and will create a file 1.xml
Well…the script is bellow, run it on a machine with CM12/CM12 R2 Console. don’t forget to run as administrator 🙂
$XMLFiles = Get-ChildItem $env:SMS_ADMIN_UI_PATH.Replace("bin\i386","XmlStorage\ConsoleRoot") -Include *.xml -Recurse
$Folder = $env:SMS_ADMIN_UI_PATH.Replace("bin\i386","XmlStorage\Extensions\Actions")
foreach ($file in $XMLFiles)
$Content = gc $file
foreach ($line in ($Content | Select-String -Pattern "NamespaceGUID="))
$arrNamespace = $line.ToString() -Split("NameSpaceGUID=")
$ConsoleGUID = ($arrNamespace -split '"')
New-Item -Path $Folder -Name $ConsoleGUID -ItemType Directory -Force
<ActionDescription Class="Group" DisplayName="$($ConsoleGUID)" MnemonicDisplayName="Test" Description="Test"><ShowOn><string>DefaultHomeTab</string><string>ContextMenu</string> </ShowOn><ActionGroups> <ActionDescription Class="Executable" DisplayName="Test1" MnemonicDisplayName="Test1" Description = "Test1" RibbonDisplayType="TextAndSmallImage"><ShowOn><string>ContextMenu</string><string>DefaultHomeTab</string></ShowOn><Executable><FilePath>test.exe</FilePath><Parameters></Parameters></Executable></ActionDescription></ActionGroups></ActionDescription>
"@ | Out-File -FilePath "$($Folder)\$($ConsoleGUID)\1.XML" -Force