Unable to add printer driver using Add-PrinterDriver on 2012 R2 Print Server

0

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:

  1. Copied the .inf, .cat and .cab files to the server
  2. Added a printer port for the printer: Add-PrinterPort -Name "TCP/IP_CanonIR" -PrinterHostAddress 10.0.0.60 -PortNumber 9100
  3. 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.

windows
windows-server-2012-r2
powershell
print-server
asked on Server Fault May 20, 2019 by Dusty Vargas • edited May 20, 2019 by Dusty Vargas

1 Answer

0

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:

# Add driver to Windows Driver Store
pnputil.exe /a C:\Path\To\driver.inf

# Find driver full path
Get-WindowsDriver -All -Online | Where-Object {$_.OriginalFileName -like '*driver.inf'} | Select-Object -ExpandProperty OriginalFileName -OutVariable infPath
# Make sure that driver.inf matches the original driver .inf file you supplied

# Get valid driver names from inf file
Get-Content -Path $infPath

# Near the top of the previous output, you should see a list of driver name to model name mappings that looks like this:
;64-bit x64
[Canon.NTamd64]
"Canon Generic Plus PS3" = GENERICPS,,1284_CID_CA_PS3_COLOR_OIP

# Based on the model on the right, since I know that is the model I have I will use that driver name:
Add-PrinterDriver -Name "Canon Generic Plus PS3" -InfPath $infPath

# You're done. Now you can run Get-PrinterDriver to be sure that it is available:
Get-PrinterDriver

Name                    PrinterEnvironment MajorVersion Manufacturer
----                    ------------------ ------------ ------------
Canon Generic Plus PS3  Windows x64        3            Canon

# You can then begin to install your printers using your newly added printer driver:
Add-Printer -DriverName "Canon Generic Plus PS3" -Location "Customer Service Department" -Shared -ShareName "Canon IR-ADV in Customer Service" -Name "Canon IR-ADV in Customer Service" -Published -PortName "TCP_10.0.0.60"
# Be sure you have already configured a printer port for the printer using the Add-PrinterPort cmdlet, and use that in the above command
answered on Server Fault May 21, 2019 by Dusty Vargas

User contributions licensed under CC BY-SA 3.0