(一)列出打印机

Get-WmiObject -Class Win32_Printer -ComputerName
(New-Object -ComObject WScript.Network).EnumPrinterConnections()

(二)添加打印机

(New-Object -ComObject WScript.Network).AddWindowsPrinterConnection("\\Printserver01\Xerox5")

设置默认打印机

(Get-WmiObject -ComputerName . -Class Win32_Printer -Filter "Name='HP LaserJet 5Si'").SetDefaultPrinter()
(New-Object -ComObject WScript.Network).SetDefaultPrinter('HP LaserJet 5Si')

(三)删除打印机

(New-Object -ComObject WScript.Network).RemovePrinterConnection("\\Printserver01\Xerox5")

您也可以关注下方微信公众号获取更多资讯
PowerShell通过COM对象配置打印机