- Windows Server 2016 Automation with PowerShell Cookbook(Second Edition)
- Thomas Lee
- 61字
- 2021-07-02 18:15:59
How to do it...
- 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