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.
This recipe uses the PSRV
print server that you set up in the Installing and sharing printers recipe.
Get the printer objects from WMI:
$Printers = Get-CimInstance -ClassName Win32_Printer
Display the number of printers defined on PSRV:
'{0} Printers defined on this system' -f $Printers.Count
Get the sales group printer WMI object:
$Printer = $Printers | Where-Object Name -eq "SalesPrinter1"
Display the printer's details:
$Printer | Format-Table -AutoSize
Print a test page:
Invoke-CimMethod -InputObject $Printer -MethodName PrintTestPage