This small script automatically add a driver and a printer to Windows 10
$portIP = "192.168.x.x"
$printName = "..."
$printDriverName = "..."
$inf = "\\server\...\....inf"
$shell = New-Object -Com WScript.Shell
$portName = "IP_$portIP"
# DRIVERS
$cmd = "pnputil.exe -i -a ""$inf"""
iex $cmd
Add-PrinterDriver -Name $printDriverName
# Port
$portExists = Get-Printerport -Name $portname -ErrorAction SilentlyContinue
if (-not $portExists) {
Add-PrinterPort -name $portName -PrinterHostAddress $portIP
}
# Printer
$printDriverExists = Get-PrinterDriver -name $printDriverName -ErrorAction SilentlyContinue
if ($printDriverExists) {
Add-Printer -Name $printName -PortName $portName -DriverName $printDriverName
}else{
Write-Warning "Printer Driver not installed"
}
Leave a Reply
You must be logged in to post a comment.