No matter how fervently I wish printers would just go away, it seems they're here to stay—with all their attendant jams, empty trays, and constant hunger for toner and ink. (Wouldn’t a Print to Surface, Kindle, iPad, or Google Glass feature be great?) Windows 8, however, offers some assistance in configuring and managing the infernal things in the form of 13 PowerShell cmdlets. This month, I’d like to introduce the first one—add-printerdriver—to you.
Amongst Windows 8 and’s many new PowerShell nouns are printer, printerdriver, and printjob. As we’ve seen many times over the years, what we want from printers (the actual hardware kind) is paper output, and that output comes from print jobs. Print jobs are created by the second meaning of the word printer—a purely software notion arising from when we build a connection between a given physical PC and a physical printer. To connect that physical PC to the physical printer, however, we need two other things: either a cable (probably USB) or a network connection between the two devices, and a printer driver. In other words, printer drivers enable the creation of printers (the software object type), printers create print jobs, and print jobs create the desired print output.
Manage Printer Drivers
Step one, then, is to manage printer drivers. PowerShell’s get-printerdriver, add-printerdriver, get-printerdriver, and remove-printerdriver do that. You must have local administrative powers to add or remove printer drivers with these cmdlets. (I point that out because, as you’ll see, you don’t need admin juice to add printers, once you have a given printer’s drivers loaded on a system.) The basic syntax for add-printerdriver is simple:
For example, to load the driver for a Dell 1320C, you’d type
add-printerdriver "Dell Color Laser 1320c"
As you might guess, that driver name is a “magic name” that needs to exactly match a known driver; otherwise, you’ll get errors (and unfortunately the cmdlet doesn’t take wildcards). You can, however, uncover a driver’s “magic name” fairly easily either by typing get-printerdriver on a system that already has that driver loaded or by poking around inside the .inf file associated with any printer driver. Browse the file a bit, and you’ll see a block that looks like this:
; ; Model sections. [DELL] "Dell Color Laser 1320c" = DLHSNZP1,LPTENUM\DellColor_Laser_132010D5 "Dell Color Laser 1320c" = DLHSNZP1,USBPRINT\DellColor_Laser_132010D5
It goes on for a bit more, but you can see that there’s a string after the vendor name, and that’s usually the “magic name” for the driver.
Add-printerdriver is great, but it promises more than it delivers. The examples that you’ve seen so far show that you can fairly simply add new printer drivers to your system—as long as they’re currently in the driver store. Of course, Windows 8 systems (like Windows 7 systems) ship with a lot of drivers, but what about installing new ones? According to the documentation, you can load a driver that isn't already in your system’s driver store with the -infpath option, as in
add-printerdriver -name "Waxtronic 320" -infpath "c:\drivers\waxtronic\wi949.inf"
In fact, Microsoft seems so sure of this capability that the –infpath option and the driver name are built in as positional parameters, letting you type the above as
add-printerdriver "Waxtronic 320" "c:\drivers\waxtronic\wi949.inf"
But, unfortunately, neither formulation seems to work, and even the most probing Bing or Google search—"Why doesn’t the -infpath option work?”—brings either no help or clueless help. Next version, perhaps. Until then, the much older Pnputil command might help. First appearing in Windows Vista, Pnputil offers some nice driver management help, including the ability to install any given driver (or drivers, for that matter—it can tackle a whole folder of them) with the -i and -a switches, as in
pnputil –i –a "c:\drivers]waxtronic\wi949.inf"
This command usually works, and it will report back that it has installed that driver package as OEMnn.inf (where nn is a number) and in the C:\windows\inf folder, letting you open up that .inf file with Notepad and search for its English driver name. Please understand, however, that no matter how many times you try Pnputil or set-printerdriver, you won't convince Windows 8 to use pre-Vista drivers.
Ready to Use Them?
Oh, and two more points here. First, when you’re typing that printer driver’s name in an add-printerdriver command, you needn’t worry about case. Second, if you decide to give Pnputil a chance, remember that it’s not PowerShell, and so it absolutely needs to see the -i and -a parameters in that order. Try typing pnputil -a -i something, and it’ll just look at you confusedly and offer some examples of proper Pnputil syntax. OK, now that the drivers are in, let’s use them—next month!