Powershell Tools - Compare DPs
Main Menu
>
Tools
>
PowerShell Tools
Compare DPs
Handy function to compare DPs
Download
Code
$CentralSite = "SCCMVHD" $SiteCode = "007" $DP1 = "SCCMCHILD1" $DP2 = "SCCMCHILD2" $a = get-wmiobject sms_distributionpoint -namespace ` root\sms\site_$SiteCode -computer $CentralSite | where{$_.ServerNALPath -like "*$DP1*"} | select-object PackageID $b = get-wmiobject sms_distributionpoint -namespace ` root\sms\site_$SiteCode -computer $CentralSite | where{$_.ServerNALPath -like "*$DP2*"} | select-object PackageID $c = compare-object $a $b -property PackageID $c
Documentation
One of the nice features for ConfigMgr is the Copy Packages Wizard Using the wizard, you're able to select packages to copy to a distribution point based on packages at an existing distribution point. While this is a great feature, there is some room (or at least suggestions) for improvement. Depending on what you want on that distribution point, you may need to use the wizard up to six times (Packages, Software Updates, Boot Images, Operating System Images, Operating System Install Packages, Driver Packages). In a future article, we'll discuss a PowerShell function I've been working on to help make that process easier--it's not quite production-ready yet :). So for now, let's focus on comparing two Distribution Points, and displaying their differences. Use the SMS_DistributionPoint Class from the ConfigMgr SDK to show Packages that have been deployed to distribution points: get-wmiobject sms_distributionpoint -namespace root\sms\site_007 -computer SCCMVHD Running the command above will display distribution point info for all packages, for the current site, and for all child sites. If we run that same command and append | get-member, we can see all properties for the SMS_DistributionPoint class. You can also format output a little better, as mentioned in a previous article For this example, we're only interested in looking at the PackageID for now. So our main command will look like this: get-wmiobject sms_distributionpoint -namespace root\sms\site_007 -computer SCCMVHD | select-object PackageID For this example, assume we have a central site (SCCMVHD) and two child sites (SCCMCHILD1 and SCCMCHILD2), each with a distribution point. Here is the code to generate our compare: $CentralSite = "SCCMVHD" $SiteCode = "007" $DP1 = "SCCMCHILD1" $DP2 = "SCCMCHILD2" $a = get-wmiobject sms_distributionpoint -namespace ` root\sms\site_$SiteCode -computer $CentralSite | where{$_.ServerNALPath -like "*$DP1*"} | select-object PackageID $b = get-wmiobject sms_distributionpoint -namespace ` root\sms\site_$SiteCode -computer $CentralSite | where{$_.ServerNALPath -like "*$DP2*"} | select-object PackageID $c = compare-object $a $b -property PackageID $c The first four lines are used to set our required variables. $a will contain all PackageIDs assigned to the distribution point on SCCMCHILD1. $b will contain all PackageIDs assigned to the distribution point on SCCMCHILD2. We then use the Compare-Object cmdlet to compare the two, and then display the result in $c. Notice the -property PackageID - this is how to specify the PackageID property for comparison. Here are the results from my test environment: View Image Notice the SideIndicator column -- the arrow pointing left indicates that the PackageID was found in the left comparison object. So LAB0009D is in $a, but not in $b. Now that we have this data, we could programmatically add these packages to the desired distribution points (we'll save that for a later article). Note: If you have a multi-tiered hierarchy, you may need to perform this procedure at different levels, depending on which site(s) you use to deploy packages packages. For "complete" results, you may need to query the SMS_DistributionPoint class on the child site directly ---created by: Greg Ramsey