Link to home
Start Free TrialLog in
Avatar of Ding QB
Ding QBFlag for Hong Kong

asked on

Powershell script to install printer

Hi experts,

Is there Powershell script to install printer with given IP address , driver inf file, printer name ? Thanks.
Avatar of hdhondt
hdhondt
Flag of Australia image

Try using the following commands:

To create the port:
CSCRIPT.EXE //NoLogo portmgr.vbs -a -c \\PC_name -p port_name -h Port_IP -t raw -n 9100 -md

To install a printer on that port:
RUNDLL32.EXE PRINTUI.DLL,PrintUIEntry /r port_name /ii /f %windir%\inf\ntprint.inf

For more info see:
https://www.robvanderwoude.com/2kprintcontrol.php
https://www.robvanderwoude.com/files/addipprn_nt.txt
https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/cscript
https://docs.microsoft.com/en-us/powershell/module/printmanagement/add-printer?view=win10-ps

Add-Printer
Add-Printerport
Add-Printerdriver

will do the job

i.e.
Add-PrinterDriver -Name "Driver Name"  -InfPath you.inf
Add-PrinterPort -Name "TCPPort:" -PrinterHostAddress "192.168.100.100"
Add-Printer -Name "yourprinter" -PortName "TCPPort:"-DriverName "Driver Name" 

Open in new window

This question needs an answer!
Become an EE member today
7 DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.