Share via


Install Printer Drivers with PowerShell in Windows 8

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.

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.

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

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.

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....(read more)