24/7/365 Support

Retrieve Printer Queue Statistics

Problem

You want to get information about print queues for printers on the current system.

Solution

To retrieve information about printers attached to the system, use the Win32_ PerfFormattedData_Spooler_PrintQueue WMI class:

PS >GetWmiObject Win32_PerfFormattedData_Spooler_PrintQueue | >> Select Name,TotalJobsPrinted >>

Name TotalJobsPrinted

Microsoft Office Document Image Wr...

0 Microsoft Office Document Image Wr...

0 CutePDF Writer

0 Brother DCP1000

2 _Total

2

To retrieve information about a specific printer, apply a filter based on its name, as shown in Example 244.

Example 244. Retrieving information about a specific printer

PS >$queueClass = "Win32_PerfFormattedData_Spooler_PrintQueue" PS >$filter = "Name='Brother DCP1000'" PS >$stats = GetWmiObject $queueClass Filter $filter PS >$stats | FormatList *

AddNetworkPrinterCalls : 129 BytesPrintedPersec : 0 Caption : Description : EnumerateNetworkPrinterCalls : 0 Frequency_Object : Frequency_PerfTime : Frequency_Sys100NS : JobErrors : 0 Jobs : 0 JobsSpooling : 0 MaxJobsSpooling : 1 MaxReferences : 3 Name : Brother DCP1000 NotReadyErrors : 0 OutofPaperErrors : 0 References : 2 Timestamp_Object : Timestamp_PerfTime : Timestamp_Sys100NS : TotalJobsPrinted : 2 TotalPagesPrinted : 0

To retrieve specific properties, access as you would access properties on other PowerShell objects:

PS >$stats.TotalJobsPrinted

Discussion

The Win32_PerfFormattedData_Spooler_PrintQueue WMI class provides access to the various Windows performance counters associated with print queues. Because of this, you can also access them through the .NET Framework.

$printer = "Brother DCP1000" $pc = NewObject Diagnostics.PerformanceCounter "Print Queue","Jobs",$printer $pc.NextValue()

Help Category:

Get Windows Dedicated Server

Only reading will not help you, you have to practice it! So get it now.

Processor RAM Storage Server Detail
Intel Atom C2350 1.7 GHz 2c/2t 4 GB DDR3 1× 1 TB (HDD SATA) Configure Server
Intel Atom C2350 1.7 GHz 2c/2t 4 GB DDR3 1× 128 GB (SSD SATA) Configure Server
Intel Atom C2750 2.4 GHz 8c/8t 8 GB DDR3 1× 1 TB (HDD SATA) Configure Server
Intel Xeon E3-1230 v2 3.3 GHz 4c/8t 16 GB DDR3 1× 256 GB (SSD SATA) Configure Server
Intel Atom C2350 1.7 GHz 2c/2t 4 GB DDR3 1× 250 GB (SSD SATA) Configure Server

What Our Clients Say