Leveraging WMI, you can easily view and manipulate print queues on a print server via PowerShell. You can do anything from building a Print Queue, deleting a print queue and cancelling all print jobs on an existing queue. You can also use a specific WMI class to view all print jobs that have been processed since the last reboot of a print server or the last service reset of the Print Spooler service on the print server.

While I will not go into how to build a print queue or set up a printer using PowerShell, these links here will show you some great examples on performing this. Instead, my focus in this blog post will show you how easily it is to view the statistics of each print queue on a print server or locally connected printer.

Print Server Statistics

Using the Win32_PerfFormattedData_Spooler_PrintQueue class, you can easily see what printer queues are being used and which ones are not. The statistics reset themselves when the Print Spooler service is restarted. So if a print server is rebooted, all of the data is reset. One thing I found while playing with this is that if the printer is not connected to the server or if the printer is turned off, then the statistics will not be reset even if the spooler service has been restarted. The only way for the statistics to be reset is to power on the printer or reconnect it to the server and perform the spooler reset. Using the following one-liner, you can see which queues have been used along with any that might have had an error at some point in time.

As it shows, I have one job currently being processed and two jobs total have been sent through the print spooler. Keep in mind that this is done from my laptop, so running this against a print server hosting many more printers will be more impressive.

Using this on a print server would be great to find old print queues that may remain even after a printer has long since been decommissioned or to see what printers are seeing the most usage.

Putting this into a excel spreadsheet is as simple as piping it into an Export-CSV command. You could even set up a scheduled job that checks each print server once a week and email the results to an individual or group for analysis.

You won’t be able to get that type of information from WMI. But you can look in the System log of the print server (I can’t remember the ID off of the top of my head) and you could then set a range to search for using Get-EventLog or Get-WinEvent and pipe that into Measure-Object to get the number of documents printed during that time frame.