Wednesday, February 5, 2014

Install IP Printer using Powershell

Good day,
You may want to install an IP Printer to several computers and install it locally using TCP/IP Port, in this case Windows GPO will not work as the printer that is pushed for the users is the shared printer and is not installed directly to the client computer.
This is the way to do it.
Usually if you notice that steps you made in the GUI TCP/IP Printer installation wizard, you first create the port and then select the printer that will use this port, and this is what we will do.
First we need to create the IP Port, to do this. we will need to use WMIClass called Win32_TcpIpPrinterPort

Function PortInstall {            
param ($PortName,$PrinterIP,$servername)            
$           = $PortName            
$PPrinter.Protocol       = 1            
$PPrinter.HostAddress    = $PrinterIP            
$PPrinter.PortNumber     = 9100            

PortInstall -PortName "1stFloorPrinter" -PrinterIP ""

This Function will allow you to create IP Port named as 1stFloorPrinter with IP

Now the port is created and we need to Add the printer and we will use the WMIClass Win32_Printer.
Let remmeber what we steps we do on the normal IP Printer installation.

- Select the printer Driver
- Assigning the printer to the port

Function Printerinstall {            
param ($caption,$PortName,$DriverName,$IsDefault=$false)             
$iprinter = ([WMIClass]"\\.\Root\cimv2:Win32_Printer").CreateInstance()            
$iprinter.Caption     =$caption            
$iprinter.DriverName  =$DriverName            
$iprinter.PortName    =$PortName            
$iprinter.DeviceID    =$caption            
$iprinter.Default     = $IsDefault            

Printerinstall -caption "First Floor" -PortName "1stFloorPrinter" -IsDefault $true -DriverName "HP LaserJet P3011/P3015 PCL6"

The Caption is the Name of the printer that the user will see and use
The PortName is the Port Name you create on the first set "1stFloorPrinter"
If you want to make the printer default then you can set the IsDefault to $True, other wise it will not be default.
and the DriverName is the Driver name as it appear in the INF File or in the Add New Printer Hardware list .

I hope you like this and find it useful.
Feel free to leave your comment and share this page.

No comments: