共用方式為


Use PowerShell to Test Remote Printers

Summary : Learn how to use Windows PowerShell to test remote printers.
Hey, Scripting Guy! I don’t know what it is, but for some reason printing still seems to be a pain. I mean, we have been using the network for a long time, and something as basic as printing still seems to be a problem. Whatever happened to the paperless office of the future? All we do is kill trees faster by using high-speed printers to print massive amounts of useless junk that no one reads.
Anyway, for some reason, about half of our Help Desk calls are related to print issues. To be sure, some of it is user training issues—people trying to select the wrong feature for the wrong printer. But in all honesty, not all of the print problems are user related. For example, sometimes the print spooler seems to die, and we need to restart it. My Help Desk techs can open Computer management to stop and restart the spooler service, but I would like to do this via a script. Can you help?
—RM
Hello RM,
Microsoft Scripting Guy, Ed Wilson, is here. We continue to get lots of rain here in Charlotte, North Carolina. Lots and lots of rain. The solar heaters for our pool are not doing much good these days. Oh well, maybe the sun will come out tomorrow.
The print management module
RM, you did not say if you are using Windows 8, so I am going to assume that you are. In Windows 8 (and in Surface RT, Surface Pro, and Windows Server 2012), there is a print management module called PrintManagement . It exposes the following commands:
PS C:\> Get-Command -Module PrintManagement

CommandType Name ModuleName
----------- ---- ----------
Function Add-Printer PrintManagement
Function Add-PrinterDriver PrintManagement
Function Add-PrinterPort PrintManagement
Function Get-PrintConfiguration PrintManagement
Function Get-Printer PrintManagement
Function Get-PrinterDriver PrintManagement
Function Get-PrinterPort PrintManagement
Function Get-PrinterProperty PrintManagement
Function Get-PrintJob PrintManagement
Function Remove-Printer PrintManagement
Function Remove-PrinterDriver PrintManagement
Function Remove-PrinterPort PrintManagement
Function Remove-PrintJob PrintManagement
Function Rename-Printer PrintManagement
Function Restart-PrintJob PrintManagement
Function Resume-PrintJob PrintManagement
Function Set-PrintConfiguration PrintManagement
Function Set-Printer PrintManagement
Function Set-PrinterProperty PrintManagement...(read more)