Examples:
Function called with the correct name of the package |
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!