Printing a test page

There are occasions when you may wish to print a test page on a printer; for example, after you change the toner or printer ink on a physical printer or after changing the print driver (as shown in the Changing printer drivers recipe). In those cases, the test page helps you to ensure that the printer is working properly.

Getting ready

This recipe uses the PSRV print server that you set up in the Installing and sharing printers recipe.

How to do it...

  1. Get the printer objects from WMI:
    $Printers = Get-CimInstance -ClassName Win32_Printer
  2. Display the number of printers defined on PSRV:
    '{0} Printers defined on this system' -f $Printers.Count
  3. Get the sales group printer WMI object:
    $Printer = $Printers |
      Where-Object Name -eq "SalesPrinter1"
  4. Display the printer's details:
    $Printer | Format-Table -AutoSize
  5. Print a test page:
    Invoke-CimMethod -InputObject $Printer -MethodName PrintTestPage

How it works…

In step 1, you used Get-CimInstance to return all the printers defined on this system. There's no output from this step.

In step 2, you displayed the total printers defined, which looks like this:

How it works…

In step 3, you got the printer object that corresponds to the sales group LaserJet printer, which generates no output. In step 4, you displayed the details of this printer, which looks like this:

How it works…

In step 5, you invoked the PrintTestPage method on the sales group printer (SalesPrinter1) to generate a test page on the printer. Using the printer MMC snap-in, generating a test page looks like this:

How it works…
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.218.151.44