How To: Send Content to DP Group from Monitoring Node in ConfigMgr 2012 SP1
April 18, 2013 Leave a comment
This post will demonstrate how to create a right-click action on the Monitoring->Distribution Status->Content Status tab to send content to a DP group. Sometimes when troubleshooting an issue, I realize that the content was sent to one DP for testing, and then promoted to production. The out-of-box experience requires you navigate back to the object (package, software update, application, etc) and then send content to DPs. This right-click tool will save you several clicks.
After selecting to “Send to DP Group”, you will see a PowerShell window with a prompt to choose the desired DP Group.
Of course, you could create multiple right-click items with hard coded DP Groups and actions, but for this post, we’ll use the dynamic selector shown above.
You can download the .zip file and follow the directions in the included ‘info.txt’ file for a fast deployment to your admin console. You can review additional details below.
First you must create the proper r-click context menu. Copy the following .xml, save it as “SendToDPGroup.xml”, and copy it to C:\Program Files (x86)\Microsoft Configuration Manager\AdminConsole\XmlStorage\Extensions\Actions\14214306-59f0-46cf-b453-a649f2a249e1\SendToDPGroup.xml. (Adjust the path as appropriate to your ConfigMgr Admin Console installation path).
<ActionDescription DisplayName="Send to DP Group" MnemonicDisplayName="Send to DP Group" Description = "Send package to a DP group." RibbonDisplayType="TextAndSmallImage"> <ShowOn> <string>ContextMenu</string> <string>DefaultHomeTab</string> </ShowOn> <Executable> <FilePath>PowerShell.exe</FilePath> -ExecutionPolicy RemoteSigned -File C:\PowerShell\CM12RClickTools\SendToDPGroup.ps1 "##SUB:__Server##" "##SUB:__Namespace##" "##SUB:PackageID##" "##SUB:ObjectTypeID##" "##SUB:SoftwareName##" </Executable> </ActionDescription>
Notice in the .xml we specify the -ExeuctionPolicy RemoteSigned parameter. Best practice would be to sign your scripts, but if that’s not something you can manage easily, you can use the parameter as shown to modify the execution policy for the specific instance you’re launching, instead of changing the execution policy for all script execution. Next, copy the PowerShell code below, and save it to C:\PowerShell\CM12RClickTools\SendToDPGroup.ps1
#capturing arguments: $SiteServer = $args[0] $SiteNamespace = $args[1] $SiteCode = ($args[1]).Substring(14) $PackageID = $args[2] $objectTypeID = $args[3] $SoftwareName = $args[4] $SiteDrive = $sitecode + ":" "{0} {1} {2} {3} {4} {5}" -f $SiteServer, $SiteNamespace, $SiteCode, $PackageID, $objectTypeID, $SoftwareName #Connect to PowerShell Provider: $ModulePath = (($env:SMS_ADMIN_UI_PATH).Substring(0,$env:SMS_ADMIN_UI_PATH.Length-5)) + '\ConfigurationManager.psd1' "Connecting to the Provider..." import-module $modulePath -force if ((get-psdrive $siteCode -erroraction SilentlyContinue | measure).Count -ne 1) { new-psdrive -Name $siteCode -PSProvider "AdminUI.PS.Provider\CMSite" -Root $SiteServer } cd $siteDrive "Gathering DP Group Names..." $intcounter = 1 #Create a hashtable $DPgroups = @{0 = "Name"} $DPgroups.Remove(0) Get-CMDistributionPointGroup | select Name | sort Name | % { $DPgroups += @{$intcounter = $_.Name} $intcounter++ } #Choose the DP group $dpgroups.GetEnumerator() | Sort-Object name $DPgroup = read-host "Select a DP group, by number and press [enter]" $DPGroupName = $DPgroups.get_item([int]$DPgroup) switch ($objectTypeID) { #ObjectTypeIDs from SMS_ObjectContentInfo WMI Class 2 {Start-CMContentDistribution -PackageID $PackageID -DistributionPointGroupName $DPGroupName} 14 {Start-CMContentDistribution -OperatingSystemInstallerID $PackageID -DistributionPointGroupName $DPGroupName} 18 {Start-CMContentDistribution -OperatingSystemImageID $PackageID -DistributionPointGroupName $DPGroupName} 19 {Start-CMContentDistribution -BootImageID $PackageID -DistributionPointGroupName $DPGroupName} 21 {"SMS_DeviceSettingPackage - Nothing to distribute here"} 23 {Start-CMContentDistribution -DriverPackageID $PackageID -DistributionPointGroupName $DPGroupName} 24 {Start-CMContentDistribution -DeploymentPackageID $PackageID -DistributionPointGroupName $DPGroupName} 31 {Start-CMContentDistribution -ApplicationName $SoftwareName -DistributionPointGroupName $DPGroupName} } "DP Group Targeted distributed-Use the Monitoring node to monitor DP status." Write-Host "Complete. Press any key to continue ..." $x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
Now re-launch your ConfigMgr Admin console to use the new r-click->Send to DP Group feature. As you can see from the code, we use Get-CMDistributionPointGroup to obtain all DP groups, and then create a hash table to allow us to display a simple selector. We then use Start-CMContentDistribution to send the content to the desired DP Group. Notice the required argument is based on the object type (package, application, updates deployment package, etc.), so we use a simple switch statement to determine the appropriate parameters to run.
Happy Scripting!
Greg
ramseyg@hotmail.com