Does Christmas come twice a year? If you installed the latest PDQ Inventory to get access to the PowerShell Scanner, then the answer is an absolute “yes it does.” Now that you have your hands on it, there are so many possibilities; it can be overwhelming. Why not let the sweet scripting of Nate and Colby get you started? They have quite a bit on our GitHub, and if there is something you feel like people can use, please make a pull request, and we can get it added. Out of all of the scripts there, let’s focus on ones involving Windows Updates.
Importing Required Modules
The pswindowsupdate module in PowerShell is not installed by default, so we would need to do this first to make sure the commands we use will be available. In a perfect world, you could just run a quick Install-Module and be done with it, and while the idea for that is good, there are some things to watch out for. It may not know where to look, or it may run into several issues. The first is that when importing the module, it will print out some lines saying it was done, which would return in a result and muddy up your results. So you will want to cast that to $null.
The second issue is that if it is already loaded, or it does not know where to look, you could get some errors. To avoid that, we use Try/Catch to test and handle those. So instead of the quick one-liner, to ensure we are not getting an error, we would want to put it all together in the script we have below.
Getting your Update Data
I did include the full import script here, but I would strongly recommend if you plan to use these that you get them from the GitHub, so if updates are made, you can keep your scanners up to date with a quick command.
Hopefully, this helps get the creative juices going, and you can dive into your next bit of PowerShell brilliance. This is a fantastic tool that can make you seem like an IT superstar to your peers. Dive in and have fun!
Jordan had spent his life wondering why tasks he didn’t like to do had no options to complete themselves. Eventually he had to make that happen on his own. It turned out that he enjoyed making tasks complete themselves, and PDQ thought that is something he should talk about on the internet while drinking most Thursdays on the PDQ webcast.