MECM – Quick way to redistribute packages
Hi all! In my last post I mentioned that it would be a short post however I decided to ramble on for a while so uhh sorry about that I guess (not). Here is some more quality content with a handy powershell script. Once again, TEST IN TEST AND DO YOUR RESEARCH BEFORE RUNNING MY SCRIPTS. I AM A STRANGER ON THE INTERNET. THIS CAN AFFECT PRODUCTION CONTENT DISTRIBUTION!!!!!
This one doesn’t need you to connect to MECM as it uses WMI however it does need administrative rights on the SMS Provider (usually your main site server).
Before I give you some code, try this first to find what you want to filter WMI for as there are many ways to target the packages and servers you want. I will give you a few examples in a moment.
#Enter your MECM site code in the $sitecode variable below. If you don't know what it is, you probably shouldn't be playing with MECM
$sitecode = ""
Get-WMIObject -Namespace root\sms\Site_$sitecode -Query "SELECT * FROM SMS_PackageStatusDistPointsSummarizer"
Running that should give you an idea of what objects you can use to filter WMI. This will allow you to target specific packages or distribution points. Examples:

Let’s say I have a specific distribution point that for some reason had 10 failed packages and a few packages still in progress but not progressing on it (I love MECM) and I want to go through and redistribute the packages without having to manually click on each package in the console via the DP. You can run something like this:
# Query all distribution jobs for a specific DP ( tweak as you will )
#Enter your site code here
$SiteCode = ""
#Enter the target DP name here, I am using a wildcard filter so you don't have to get the exact NALPath via MECM
$Servername = "server1name"
#This query will return all failed packages for the distribution point. The STATE portion is pretty much saying all packages not in a successful state (0)
$Jobs = Get-WMIObject -Namespace root\sms\Site_$sitecode -Query "SELECT * FROM SMS_PackageStatusDistPointsSummarizer WHERE ServerNALPath LIKE '%$Servername%' AND STATE <> 0"
#Before you run the below query which will trigger a redistribute on all of the returned packages from the query, maybe check what packages have been found by looking at what is in the $jobs variable we have just captured or even just do a count of jobs by using $jobs.count
#this block does a redistribute/refresh in a simple foreach loop
foreach ($job in $Jobs) {
$PackageID = $job.PackageID
$NALPath = $job.ServerNalPath
$server = ($NALPath -split '\\')[2]
Write-host "Trying $PackageID on $server"
$targetpackage = Get-WmiObject -Namespace root\sms\Site_$sitecode -Query "SELECT * FROM SMS_DistributionPoint WHERE PackageID='$PackageID' AND ServerNALPath LIKE '%$server%'"
foreach ($dpEntry in $targetpackage) {
$dpEntry.RefreshNow = $true
$dpEntry.Put()
}
}
As you are running the above, you should see powershell spit out results like this which is a good indication it’s doing what you want. The results should be outputting the dp name and the package name.

Remember to test in test and have a play around with what you want to target via the WMI filter in the script. You can do things like target all failed packages in your environment or filter using a specific package id. You could also get even more creative and write up a script that runs each night using task scheduler or something.
This alone has saved me MAAAANNYYY hours and your fellow techs will love you for it.
I recommend playing around with WMI explorer on the server and having a browse around the namespace in the script to see what you can see. You will be surprised at all the things you can do and methods you can research!
Hmm… I think I should write a nice outro line or something … uhhh… peace out?

1 Response
[…] I am going to cut this even shorter than last one. -> Redistributing packages https://travfindsthings.org/2025/08/26/mecm-quick-way-to-redistribute-packages/ […]