What's the Add-PrinterDriver equivalent in Powershell 2.0?

Hi everyone,

The Add-PrinterDriver command is only available with Powershell 3.0 and higher.
I am looking though for the equivalent of this command or how to build one in Powershell 2.0 (for Win7 computers).

Important: I am not looking to install a driver. The driver is already installed on the devices. I just need to add it as a printer driver.

If you’re wondering what the difference between installing and adding is:

  • Add-PrinterDriver is somehow a “registration” of a driver which is already existing on the computer. It makes it appear in the PrintManagement Console under Drivers :slight_smile: Not sure how to better explain it.
    I am looking for the same functionality under Win7.

I need this because we are having some problems with certain drivers and reinstalling them does not help, but “re-registering” them fixes our problem.
Thanks for any suggestion!

You could look into the command:

rundll32 printui.dll,PrintUIEntry

Thank you!
Here’s the command which seems to work the same:

rundll32 printui.dll,PrintUIEntry /ia /K /m “Canon Generic Plus PCL6” /h “x64” /v 3 /f “C:\Windows\Temp\Driver<filename>.inf”

Not Powershell, but seems to do the same!

Cheers!

Yep, that will do it, and doing it in PSv2 is a lot more wordy.

Stuff like…

$printerclass = [wmiclass]'Win32_Printer'
$printer = $printerclass.CreateInstance()
$printer.Name = $printer.DeviceID = 'New Printer'
$printer.PortName = 'LPT1:'
$printer.Network = $false
$printer.Shared = $false
$printer.DriverName = 'HP LaserJet 2200 PCL5'
$printer.Put()

But you could turn that into a function, call it Add-Printer and put in your profile for later use.

You also could have just used the built in Windows printui.exe in a script.