Wednesday, May 16, 2018

Quick and Dirty SCCM Application Deployment Reporting

For this blog, I'm going to go over a very basic script I wrote to quickly get application deployment statuses without having to use the Configuration Manager GUI console. I find the Reporting\Deployments tab very slow to respond, and you still have to dig into each individual app if you want details.  What this function does is allow you to specify what you think is the name of the application and it will find anything like it, allow you to select the one you want, and then it will run a deployment summarization and output the results. 

Examples:
Function called with the correct name of the package
In this example, "Tanium Client" is the actual name of a software package, so it doesn't need to pop up a prompt asking us which one we actually wanted.

Function called with a keyword instead of the full package name

After package was selected from the pop up

In the above two images, I didn't remember the full name of my Tripwire deployments, so I just typed "Tripwire" and let it look for it for me.  

The Code:

This is a fairly simple piece of code, but I wrote it to run quickly.  It first checks to see if the name you gave it when running already matches a software package. If not, it runs a WMI query (much faster than using Get-CMApplication with a where-object piped on) to look for anything like what you entered. It puts all results into an array which then selects the LocalizedDisplayName and filters out duplicates. Those unique values are then handed over to Out-GridView, which thanks to the -passthru flag assigns the selected result to our original $SoftwareName variable.  You'll also see that I have to specify that I want the ".localizeddisplayname" NoteProperty. If you don't do this, you'll see the selected software name as "@LocalizedDisplayName={'Whatever your name was'}"
After that selection process, everything proceeds as normal. It gets the CMDeployment object for that application and runs the Invoke-CMDeploymentSummarization cmdlet which refreshes the deployment status, gets you current numbers, etc.  After that, I have it get the deployment again and select what I found to be the relevant values for a list formatted report.  Because SummarizationTime is done in UTC, I have it convert to client local time for ease of reporting, and I also go ahead and do a quick math expression for the percent success, which is done with the Round function so we don't get a dozen decimal places of needless precision.   The Query Time value was mostly tacked on at the end so the people I was getting this information for could see that the data was current.  

Hopefully this is useful for someone out there. Thanks for reading!