我是靠谱客的博主 无辜吐司,最近开发中收集的这篇文章主要介绍PowerShell中使用PrintManagement管理打印机示例,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

适用于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函数,而不是编译的二进制命令。

最后

以上就是无辜吐司为你收集整理的PowerShell中使用PrintManagement管理打印机示例的全部内容,希望文章能够帮你解决PowerShell中使用PrintManagement管理打印机示例所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(184)

评论列表共有 0 条评论

立即
投稿
返回
顶部