Managing Printers

by Jan 16, 2015

Windows 8.1 or Server 2012 R2

Both Windows 8.1 and Server 2012 R2 come with a module called “PrintManagement”. It includes all cmdlets needed to manage local and remote printers.

Here is a sample script that installs a printer driver and a printer port, installs a printer, shares it, and sets some printer properties.

$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 

To play with it, make sure you adjust $IPAddress and have it point to some existing printer. Change $ComputerName to apply the changes to a remote machine instead of your own local machine.

To list all cmdlets found in PrintManagement module, try this:

 
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
 

As you see, these are really PowerShell functions rather than binary cmdlets.

Twitter This Tip! ReTweet this Tip!