I try to take 1 day out of the week to manage the health of my SCCM infrastructure. One of the activities I was doing every Monday was checking the status of each package. If it failed, I'd then have to check the distribution point that it failed on and troubleshoot why it failed. It was extremely time consuming. One of my ongoing projects is to automate the majority of this infrastructure health check. This one-liner is my first contribution.

This is an extremely simple one-liner. However, the problem was not writing the script; it was finding out where the data I needed was stored in WMI. Luckily, with a little persistence, I was able to make it happen.

I haven't changed it up much from that post but what I did do is simply output the package ID and the DP that the failure occurred on. I also used a calculated field to ping the DP as well since sometimes those often-forgotten remote DPs are switched off by users on occasion.

$query = 'SELECT * FROM SMS_PackageStatusDistPointsSummarizer WHERE State = 2 OR State = 3'
Get-WmiObject -ComputerName SERVER_NAME -Namespace 'root\SMSSite_SITECODE' -Query $query |
    Select-Object packageID,@{n='DistributionPoint';e={$_.ServerNALPath.Split('')[2]}},@{n='DPOnline';e={Test-Connection $_.ServerNALPath.Split('')[2] -Quiet}} |
        Format-Table -AutoSize

Join the Jar Tippers on Patreon

It takes a lot of time to write detailed blog posts like this one. In a single-income family, this blog is one way I depend on to keep the lights on. I'd be eternally grateful if you could become a Patreon patron today!

Become a Patron!