PowerShell 4.0添加打印机

时间:2014-01-24 22:03:07

标签: powershell printing scripting powershell-v3.0 printers

我刚刚在我的Win7 SP1盒子上安装了PowerShell 4.0,(从2.0原生版本开始)。 PowerShell 3.0应该包含一些方便的打印机专用功能,如Add-Printer,Add-PrinterDriver等,但在我的盒子上运行'Get-Command'并没有显示任何命令我是寻找。

我是否必须安装PowerShell 3.0才能获取它们?

2 个答案:

答案 0 :(得分:4)

“PrintManagement”模块,其中包含您在Windows 8 / Windows Server 2012上使用PowerShell v3时提到的命令 从某种意义上说,它与操作系统相关联,而不是直接与PowerShell版本相关联。

    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

答案 1 :(得分:-1)

PowerShell共享和取消共享打印机 http://winplat.net/2015/12/04/powershell-to-share-and-unshared-the-printers/

共享打印机

Set-Printer -Name DummyPrinter -Shared $True -Published $True -ShareName MyDummyPrinter

在远程计算机上共享打印机

Set-Printer -Name DummyPrinter -Shared $True -Published $True -ShareName MyDummyPrinter -ComuterName PrintSvr01

其中, DummyPrinter是打印队列的名称, MyDummyPrinter是所需的共享名称 PrintSvr01是托管打印机的远程服务器。

请注意,参数-Publish启用了“目录列表”选项。如果您不想要该选项,可以省略。

多台打印机?

get-printer -ComputerName PrintSvr01 | foreach{Set-Printer -name $_.name -Shared $true -ShareName $_.name -Published $true -ComputerName PrintSvr01}

取消共享打印机

要取消共享,请将-Shared参数设置为$ False Set-Printer -Name DummyPrinter -Shared $True -ComuterName PrintSvr01