Install Printer Drivers with PowerShell in Windows 8

Install Printer Drivers with PowerShell in Windows 8

  • Comments 4
  • Likes

Summary: Microsoft Scripting Guy, Ed Wilson, talks about using Windows PowerShell in Windows 8 to install printer drivers.

Microsoft Scripting Guy, Ed Wilson, is here. This morning, it is rainy and overcast here in Charlotte, North Carolina, but it is pleasantly cool. The Scripting Wife migrated to the lanai and is sitting on her swing and checking Facebook on her Windows RT Surface. I am in my office checking email sent to scripter@microsoft.com. I am sipping a cup of English Breakfast tea with a cinnamon stick, lemon grass, hibiscus blossom, orange peel, and a bit of spearmint. It is a very refreshing cup of tea.

When it comes to using Windows PowerShell to install print drivers, there is the long way and the short way. The long way is…well…long and rather complicated. The short way is easy. The difference in the two methods is not necessarily a conscious choice, but rather a function of the drivers already installed in Windows and the print device you intend to hook up.

For example, we all know that Windows ships with a whole bunch of printer drivers already on the disk. They reside in the Windows\inf folder, and they all begin with the letters prn. The following script lists the printer drivers that ship with Windows.

Get-ChildItem ((Get-Item Env:\systemroot).value+"\inf") -Exclude *.pnf -recurse |

Where-Object { $_.name -match "prn" } |

Sort-Object -Property name |

format-table -Property name, length, creationTime, lastWriteTime -AutoSize

Of course, one issue is a bit convoluted. The following image illustrates the output.

Image of command output

The issue is that the names, such as prnbrcl1.inf, do not make too much sense. I can go to the Windows/inf directory, and open the .inf file in Notepad, and I am greeting with something that looks like the following.

Image of file content

If I compare this output with the output from the advanced printer installation dialog box, I can see similarities. This is shown here.

Image of menu

If I select a printer driver from the previous list, and click Next, the driver installs. I can verify this via the Get-PrinterDriver function, as shown here:

Get-PrinterDriver

The following image shows the command and its output.

Image of command output

I can then use the Get-PrinterDriver function to retrieve the newly installed printer:

Get-PrinterDriver -Name "Brother *"

If I attempt to remove it, however, an error message appears, which states that it is being used by a printer. This command and the error message are shown here.

Image of error message

After I remove the printer that uses the driver, I can then remove the printer—but that is tomorrow’s blog post.

To add a printer driver that exists in the driver store, I need to use the actual driver name. I cannot use wildcard characters, or an error message appears. For example to install the "Brother Laser Leg Type1 Class Driver" that I found in the .inf files, I must use the complete name. This command is shown here:

Add-PrinterDriver -Name "Brother Laser Leg Type1 Class Driver"

If I attempt to use Brother *, an error occurs. This message is shown in the following image.

Image of error message

I can also use the Add-PrinterDriver function to install a print driver by specifying the name of the .inf file for that printer driver. One issue is that often printer drivers are “universal drivers,” and the .inf file contains information for dozens of printers. Therefore, Windows PowerShell will not know which driver to install.

That is all there is to using Windows PowerShell to install printer drivers. Printer week will continue tomorrow when I will talk about removing printers.

I invite you to follow me on Twitter and Facebook. If you have any questions, send email to me at scripter@microsoft.com, or post your questions on the Official Scripting Guys Forum. See you tomorrow. Until then, peace.

Ed Wilson, Microsoft Scripting Guy

Your comment has been posted.   Close
Thank you, your comment requires moderation so it may take a while to appear.   Close
Leave a Comment
  • Hello! Thank you for the post! A tried to install additional drivers from powershell, but I failed. Let's presume I installed a printer with 64bit Win7 driver and shared it correctly by powershell. How can I install a secondary x32 windows XP driverer to this share by powershell? Any tips?

  • Hello Great Article..........................Fantastic ink pad reset Thanks for sharing

  • Hi, I am writing a script to create printers (on Server 2012 R2) using a WMI exported CSV file from a Server 2008 R2 Print Server and I would like to 'try' to add a printer and 'catch' specifically the 'The specified driver does not exist' error so that I can then attempt to try and add the driver. Can you point me in the right direction? Nice article, many 'The Scripting Guys' articles have helped me resolved PowerShell issues. Thanks.

  • As far as i can tell Add-PrinterDriver does not work, or at least it is insufficiently documented to give you enough information to make it work. I have spent vast amounts of time trying to get it to work with the goal of documenting and automating the transfer of my users' installed printers to a new or rebuilt PC. I can successfully use Add-Printer for printers whose drivers are in the store. I can use the GUI to add drivers so that Add-Printer will in fact add the printer. But no matter what I have tried, i have been completely unsuccessful in pointing to an inf store and adding a printer driver. I've never found anyone who has successfully made it work. I am not sure anyone has tried. Other than me. And I failed.