Windows/Powershell: Allow printers on a printer server to be ‘list in the directory’ and change the default ‘autodetect’ print drivers

Created: 1/15/20

Updated: 1/15/20

Yet another script that was written after running into a task I just didn’t want to do manually. Meanwhile it took me 10 minutes to write this, probably saved me over 30 minutes to do this manually.

Enjoy!

# Get all printers in the Print Management and change them to “list in the directory” aka Published
Get-Printer | Set-Printer -published $true

# Sniff out all Print Drivers that show the “autodetect” driver of ‘Microsoft PWG Raster Class Driver’
# and change it with the proper print driver ‘Samsung B/W Laser PCL6 Bi-di Class Driver’
$printdrivers = “Samsung B/W Laser PCL6 Bi-di Class Driver”

$printers = gwmi win32_printer

foreach($samsungprinter in ($printers |Where{$_.DriverName -like ‘*Microsoft PWG Raster Class Driver*’}))
{$printername = $samsungprinter.name
& rundll32 printui.dll PrintUIEntry /Xs /n $printername DriverName $printdrivers
}

#See Results
Get-Printer |Where {$_.DriverName -like ‘*Samsung B/W Laser PCL6 Bi-di Class Driver’} | Format-Table -Property Type,DriverName,Published -AutoSize

Cheers! 🙂

-Trevor