We starting running low on space on a few of our DPs the other day, so I looked for a quick way to free some disk space. I found that some of our Driver Packages were distributed to DP groups and a few individual DPs that didn’t need to be. A little PowerShell and we were able to free up over 20GB!

The script is simple, and does not have much logic built in, but it works and took just a few minutes to write. When you mess with content on DPs for a package in the console, it can be a bit flaky sometimes. We have seen when removing DP groups, you have to do things in a certain order and if you remove a DP group it removes all servers in that group as well!

For the script we simply add the DP group we want to be on all the Driver Packages, then remove the ones we dont! In this case ‘DP Group 03’ is the only DPs we want content distributed to. We are removing it from ‘DP Group 01’, ‘DP Group 02’, ‘SERVER01’ and ‘SERVER02’.

1 2 3 4 5 6 7 8 Get-CMDriverPackage | foreach { Start-CMContentDistribution -DriverPackageId $_ . PackageID -DistributionPointGroupName "DP Group 03" -ErrorAction SilentlyContinue Remove-CMContentDistribution -DriverPackageId $_ . PackageID -DistributionPointGroupName "DP Group 01" Remove-CMContentDistribution -DriverPackageId $_ . PackageID -DistributionPointGroupName "DP Group 02" Remove-CMContentDistribution -DriverPackageId $_ . PackageID -DistributionPointName "SERVER01.FQDN" Remove-CMContentDistribution -DriverPackageId $_ . PackageID -DistributionPointName "SERVER02.FQDN" }

That is it!