The Collection Library
PDQ Inventory’s, Collection Library, is a powerful tool that ensures you are targeting computers with schedules accurately. It also gives you a current display of what machines are patched or have outdated software. Even if your business has specific software or other applications that are not in the Collection Library, PDQ still has your back. We can also make sure specific config files are updated when they are scheduled.
Automatically update custom variables
Sick of updating custom variables for your business’ applications? Are you curious about those updated config files? And would you like to verify that all machines match a reference number? If so, you’ve come to the right place. In this post, we’ll show you how to leverage PowerShell, and some new command line functionality in PDQ Inventory (15.1.0.0 or newer) to keep those custom variables up to date.
Note: This assumes that you already have your custom variables setup. The commands we use are update commands, not creation commands.
You’ll also need a “reference computer.” One that you manage and make sure is patched. We will also grab version numbers and modified dates from this machine. If it’s not patched your variables aren’t going to update. We’ll also assume that our PDQ console machine has all applications installed and that you’ve done your job keeping them patched. You must also be sure that it has those config files, and that they are the correct version.
Reality check
Based off of what was previously discussed, chances are this isn’t the case. It’s more likely a sacred VM that no one knows exists. In this case, depending on where you want to run the scripts (PDQ console or Reference PC) you can wrap a section of the script into an Invoke-Command to keep things working as intended.
The basic premise
First, we’re going to use PowerShell to get some item properties. Let’s tackle VLC first. VLC writes its version number to:
HKEY_LOCAL_MACHINE\SOFTWARE\VideoLAN\VLC\Version
So let’s define a variable (for management sake, it will be easiest to name these the same as your PDQ Inventory variables). This variable will hold the value (Version number in our case) that we want to use to update our PDQ variables:
$VLCVER = Get-ItemPropertyValue -Path
"Registry::HKEY_LOCAL_MACHINE\SOFTWARE\VideoLAN\VLC" -Name Version
Now that we have our version string stored in the variable $VLCVER we can then call PDQ Inventory’s command line to update its variable with the data stored within $VLCVER:
pdqinventory updatecustomvariable -Name VLCVER -Value "$VLCVER"
When you put the whole thing together this is the output you should get:
If you want to make sure that value was updated, you can always look at the DB:
Wrapping collection into an Invoke-Command
Remember when we were talking about wrapping these up into an Invoke-Command? Here is how that could look (running the script on the “reference computer”):
Invoke-Command -ComputerName $pdqserver -Credential $creds -ScriptBlock{
pdqinventory updatecustomvariable -Name VLCVER -Value $($Using:VLCVER)
}
Next, let’s tackle a funconfig.xml and make sure that its ‘LastWriteTime’ value is up to date. This is going to be almost exactly like the registry value we just looked at, but this time we’ll look at a different property name ‘LastWriteTime.’
$CONFIGFILE = Get-ItemPropertyValue -Path "C:\funconfig.xml" -Name LastWriteTime
Then we’ll let PDQ Inventory know we’re going to update this again:
pdqinventory updatecustomvariable -Name CONFIGFILE -Value "$CONFIGFILE"
Now let’s put both of them together and we can continue to build out our script in this fashion:
$CONFIGFILE = Get-ItemPropertyValue -Path "C:\funconfig.xml" -Name LastWriteTime
$VLCVER = Get-ItemPropertyValue -Path "Registry::HKEY_LOCAL_MACHINE\SOFTWARE\VideoLAN\VLC" -Name Version
pdqinventory updatecustomvariable -Name CONFIGFILE -Value "$CONFIGFILE"
pdqinventory updatecustomvariable -Name VLCVER -Value "$VLCVER"
Note: Because we are looking for files here, make sure you have your file scanner set up in PDQ Inventory (Insert link to file scanner KB).
Here is what mine looked like when writing this:
Once you have this built out, there’s no sense in automating only one part of it. So continue your journey by setting this script up to run as a scheduled task. You can watch this video for more information on how to move forward.
Creating your own collections
Now we’ve scheduled a task, and we’re updating variables like magic. So let’s make some collections and take action on the data we’ve compiled. Since we need to make some dynamic collections, let’s circle back to the Collection Library. It’s an awesome resource for creating your own collections. No sense in re-inventing the wheel right? Simply, find a collection that best fits what you are trying to accomplish. Previously we were looking at VLC, so let’s take a peek at what the VLC collection looks like in the library.
Here is what the “Latest, (up to date) collection looks like”:
You can see that we use variables (system), but they function the same as the custom variables you just set up. You can right-click on that collection from the library, and select ‘duplicate.’
The duplicated collection will show up as a regular Dynamic collection in your tree, and now we have a template to work off of. Then, we can replace the system variables with our custom variables.
Now our collection is done.
Repeat the process for the old and not-installed collections from the library. Now you have your very own custom collection library that updates on the fly.
Taking it even further
Want to sort your collections into folders like PDQ Deploy? No problem. Create a new dynamic collection with just a name and a single filter. Then drag any collections you want into it from the tree like this:
Wrapping up
The Collection Library is a powerful tool that allows you to target computers with schedules accurately, as well as display patched or outdated machines. Even if you have specific software that only your company uses, we still have your back. It’s easy to create your own custom collections. We can also make sure specific config files are updated when they are scheduled.