I'm trying to setup a Windows Server 2012 R2 host as a print server. I'm at the early stage of trying to add a printer to the system. I'm trying to keep this as PowerShell based as possible, but I've resorted to using plain old .exe utilities as well (specifically due to the shortcomings in Add-WindowsDriver
). Really, I'm trying my best to avoid the GUI.
Powershell version is 5.1.
Thus far, I've performed these steps in trying to install the printer:
- Copied the .inf, .cat and .cab files to the server
- Added a printer port for the printer:
Add-PrinterPort -Name "TCP/IP_CanonIR" -PrinterHostAddress 10.0.0.60 -PortNumber 9100
- Added the printer driver to the Windows Driver Store:
pnputil.exe /a C:\PrintDrivers\Canon\Driver\driver.inf
Here is where I'm stuck. I can't seem to use Add-PrinterDriver
. I learned through Googling that I first need to add the driver to the WDS (which I've now done with pnputil.exe
) but I still can't seem to add it. I run Get-WindowsDriver
and I see it returned. Based on the OriginalFileName
property of the returned object, I know the location of the .inf file in the driver store. So, I run the following:
Add-PrinterDriver -Name "Canon imageRUNNER ADVANCE" -InfPath "C:\Windows\System32\DriverStore\FileRepository\cns30ma64.inf_amd64_3fa1ebf9a5a06bfe\cns30ma64.inf"
What that returns is:
Add-PrinterDriver : The specified driver does not exist in the driver store.
+ CategoryInfo : NotSpecified: (MSFT_PrinterDriver:ROOT/StandardCimv2/MSFT_PrinterDriver) [Add-PrinterDriver], CimException
+ FullyQualifiedErrorId : HRESULT 0x80070705,Add-PrinterDriver
I also tried specifying the value of the Driver
property returned by Get-WindowsDriver
as the provided value for -Name
:
Add-PrinterDriver -Name "oem13.inf" -InfPath "C:\Windows\System32\DriverStore\FileRepository\cns30ma64.inf_amd64_3fa1ebf9a5a06bfe\cns30ma64.inf"
That returns the same error. I've read the help for Add-PrinterDriver
and it isn't very helpful. I know that the -InfPath
value is valid, as that is the correct path as returned from Get-WindowsDriver
. The only other thing I'm specifying is -Name
. From the help:
-Name <String>
Specifies the name of the printer driver.
That, to me, sounds like I can name it whatever I want so I don't see a problem there. Everything done here is being run in an elevated shell so accessing contents of the driver store shouldn't be a problem.
Does anyone have any advice here? Am I going about this the wrong way? Please let me know if I can provide any other relevant information.
Best Answer
Alright, I figured it out. With the
-Name
parameter you need to specify a valid name for that driver, according to the available names in the .inf file. This is the name that shows up when you manually select a driver while installing a printer. So, for example, if you want to add a printer driver for a Canon printer: