适用于Windows 8.1或者Windows Server 2012 R2
Windows 8.1和Windows Server 2012 R2引入了一个组件:“PrintManagement”,它包含了所有用来管理本地和远程机器打印机的命令。
下面的例子演示安装打印机驱动和打印机端口,先安装一个打印机,分享它,并设置一些属性。
$ComputerName = $env:COMPUTERNAME $DriverName = 'Samsung SCX-483x 5x3x Series XPS' $IPAddress = '192.168.2.107' $PortName = 'NetworkPrint_192.168.2.107' $PrinterName = 'BWPrint' $ShareName = 'Office 12' Add-PrinterDriver -ComputerName $ComputerName -Name $DriverName Add-PrinterPort -Name $PortName -ComputerName $ComputerName Add-Printer -ComputerName $ComputerName -Name $PrinterName -DriverName $DriverName -Shared -ShareName $ShareName -PortName $PortName Set-PrintConfiguration -ComputerName $ComputerName -PrinterName $PrinterName -PaperSize A4
当然,你要运行它,得确保调整变量 $IPAddress 指向真实存在的打印机地址。把$ComputerName 从本地机器名更改为远程机器名。
可以这样查看PrintManagement 组件中所有的PowerShell命令:
PS> 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 Read-PrinterNfcTag 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 Function Suspend-PrintJob PrintManagement Function Write-PrinterNfcTag PrintManagement
其实,它们只是一些PowerShell函数,而不是编译的二进制命令。
原文链接:managing printers
本文链接: https://www.pstips.net/managing-printers.html
请尊重原作者和编辑的辛勤劳动,欢迎转载,并注明出处!
请尊重原作者和编辑的辛勤劳动,欢迎转载,并注明出处!
请问,怎样用ps设置打印机的纸张尺寸、打印方向?
请问怎么样用这个命令让机器从打印机服务器安装驱动,类型于从explorer里双击安装?是挨个标明驱动位置和对应的打印机地址么?感觉这样好像是安装在本地了,而不是通过打印机服务器打印了