Printing Test Pages on Printers

by Dec 19, 2018

Windows 10 and Windows Server 2016 come with extensive printer support thanks to the PrintManagement module. If you’d like to print official test pages on your printers, though, you need to resort to WMI.

#requires -Version 3.0 -Modules CimCmdlets, PrintManagement

Get-Printer | 
    Out-GridView -Title 'Print test page on selected printers' -OutputMode Multiple |
    ForEach-Object {
        $printerName = $_.Name
        $result = Get-CimInstance Win32_Printer -Filter "name LIKE '$printerName'" |
            Invoke-CimMethod -MethodName printtestpage 
        if ($result.ReturnValue -eq 0)
            "Test page printed on $printerName."
            "Unable to print test page on $printerName."
            "Error code $($result.ReturnValue)."

When you run this code, a dialog opens and shows all your printers. Select one (or more, by holding CTRL), and have them print test pages. – PowerShell Conference EU 2019 – June 4-7, Hannover Germany – visit There aren’t too many trainings around for experienced PowerShell scripters where you really still learn something new. But there’s one place you don’t want to miss: PowerShell Conference EU – with 40 renown international speakers including PowerShell team members and MVPs, plus 350 professional and creative PowerShell scripters. Registration is open at, and the full 3-track 4-days agenda becomes available soon. Once a year it’s just a smart move to come together, update know-how, learn about security and mitigations, and bring home fresh ideas and authoritative guidance. We’d sure love to see and hear from you!

Twitter This Tip! ReTweet this Tip!