Script to install all print drivers from a print server

I was just preparing to write a PowerShell script to connect to a print server, enumerate all the shared printers and connect to each one which will install the required driver…. when a quick Google search turned up exactly what I was looking for. I created this batch file:

set PrintServer=PrintServerName
powershell.exe “& { $Wmi = ([wmiclass]’Win32_Printer’) ; $Wmi.Scope.Options.EnablePrivileges = $true; gwmi win32_printer -ComputerName ‘%PrintServer%’ -Filter ‘shared=true’ | foreach {$Wmi.AddPrinterConnection( [string]::Concat(‘\\’, $_.__SERVER, ‘\’, $_.ShareName) )} }”

The script is now running on a XenApp 6 server and seems to be working perfectly. Awesome, less work to do on this Sunday afternoon.

Leave a Reply

Contact Deptive

Deptive - Commercial Bay
11-19 Customs Street West St
Commercial Bay Tower, Level 17, Room 1715
Auckland 1010
We also have a virtual office in Wellington.

Contact Details

0800 000 141

Postal Address
PO Box 34797,
Birkenhead, Auckland 0746