From time to time, you may wish to print a test page on a printer, for example, after changing toner or printer ink, 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.
For this recipe, you print a test page on the Sales Group
object's LaserJet printer, as updated by the Changing printer drivers recipe.
- Get the printer objects from WMI:
$Printers = Get-CimInstance -ClassName
Win32_Printer
- Display the number of printers defined:
'{0} Printers defined on this system' `
-f $Printers.Count
- Get the
Sales Group
printer:
$Printer = $Printers |
Where-Object Name -eq "SGCP1"
- Display the printer's details:
$Printer | Format-Table -AutoSize
- Print a test page:
Invoke-CimMethod -InputObject $Printer ` -MethodName PrintTestPage