Printer Driver not found in DriverStore even though the file is there
I have a script that installs printer drivers onto a machine. It has worked perfectly for years up until yesterday. This is the script:
# This script works on Windows 8 or newer since the add-printer cmdlets are’t available on Windows 7.
# Download the HP Univeral Printing PCL 6 driver.
# To findextract the .inf file, run 7-zip on the print driver .exe and go to the folder in Powershell and run this command: get-childitem *.inf* |copy-item -destination “C:examplefolder” Otherwise it’s hard to find the .inf files.
$driversrc=”\10.1.1.21sysprepPrinter DriversApeosC2570ffac7070pcl6220420w636imlSoftwarePCLamd64Common 01FFSOBPCLA.inf”
Write-Host “Reading from here: $driversrc”
$driver = “FF Apeos C2570 PCL 6”
$address = “10.1.1.31”
$portnamesuffix = “_1”
$portname = “$address$portnamesuffix”
$name = “Admin Apeos C2570”
$sleep = “3”
# The invoke command can be added to specify a remote computer by adding -computername. You would need to copy the .inf file to the remote computer first though.
# This script has it configured to run on the local computer that needs the printer.
# The pnputil command imports the .inf file into the Windows driverstore.
# The .inf driver file has to be physically on the local or remote computer that the printer is being installed on.
Invoke-Command {pnputil.exe -a $driversrc }
Add-PrinterDriver -Name $driver
Start-Sleep $sleep
#Get the infos of all printer
$Printers = Get-WmiObject -Class Win32_Printer
$PrinterPorts = Get-PrinterPort
$PrinterName = $name
# This creates the TCPIP printer port. It also will not use the annoying WSD port type that can cause problems.
# WSD can be used by using a different command syntax though if needed.
Try
{
Write-Verbose “Get the specified printer info.”
$Printer = $PrinterPorts | Where{$_.Name -eq “$portname”}
If (! $Printer)
{
Write-Verbose “Adding printer port.”
Add-PrinterPort -Name $portname -PrinterHostAddress $address
Write-Host “$portname has been successfully added.”
}
Else
{
Write-Warning “Port already exists.”
}
}
Catch
{
$ErrorMsg = $_.Exception.Message
Write-Host $ErrorMsg -BackgroundColor Red
}
start-sleep $sleep
Try
{
Write-Verbose “Get the specified printer info.”
$Printer = $Printers | Where{$_.Name -eq “$PrinterName”}
If (! $Printer)
{
Write-Verbose “Adding printer.”
Add-Printer -DriverName $driver -Name $name -PortName $portname
Write-Host “$PrinterName has been successfully added.”
}
Else
{
Write-Warning “$PrinterName is already installed!.”
}
}
Catch
{
$ErrorMsg = $_.Exception.Message
Write-Host $ErrorMsg -BackgroundColor Red
}
Start-Sleep $sleep
#Update the infos of all printer
$Printers = Get-WmiObject -Class Win32_Printer
Try
{
Write-Verbose “Get the specified printer info.”
$Printer = $Printers | Where{$_.Name -eq “$PrinterName”}
If($Printer)
{
Write-Verbose “Setting the default printer.”
$Printer.SetDefaultPrinter() | Out-Null
Write-Host “$PrinterName has been successfully set as the default printer.”
}
Else
{
Write-Warning “Cannot find $PrinterName, can’t set it as the default printer.”
}
}
Catch
{
$ErrorMsg = $_.Exception.Message
Write-Host $ErrorMsg -BackgroundColor Red
}
Try
{
If($Printer)
{
Write-Verbose “Setting printer defaults.”
Set-PrintConfiguration -PrinterName $PrinterName -Color $false -DuplexingMode TwoSidedLongEdge | Out-Null
Write-Host “$PrinterName has printing defaults set.”
}
Else
{
Write-Warning “Cannot find the specified printer, can’t set printer defaults.”
}
}
Catch
{
$ErrorMsg = $_.Exception.Message
Write-Host $ErrorMsg -BackgroundColor Red
}
Get-PrintConfiguration -PrinterName $PrinterName
# This prints a list of installed printers on the local computer. This proves the newly added printer works.
Write-Warning “You must manually set the printer Output Color Preference to Black and White. Do it now!”
get-printer |Out-Printer -Name $name
Write-Host “If all went well a page should be printing out on the printer now.”
When I run the commands manually, the error persists. This is the error:
Add-PrinterDriver : The specified driver does not exist in the driver store. dd-PrinterDriver -Name “[Name]” -InfPath “[Path]” PS C:WindowsSystem32] At line:1 char:1 + Add-PrinterDriver -Name “[Name]” -InfPath “[Path]” + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (MSFT_PrinterDriver:ROOT/StandardCimv2/MSFT_PrinterDriver) [Add-PrinterDri ver], CimException + FullyQualifiedErrorId : HRESULT 0x80070705,Add-PrinterDriver
I want to know if there is a reason that the driver is not getting found in the DriverStore despite my being able to locate it. And whether others have this issue, it appears as if it’s a windows issue.
I have a script that installs printer drivers onto a machine. It has worked perfectly for years up until yesterday. This is the script:# This script works on Windows 8 or newer since the add-printer cmdlets are’t available on Windows 7.# Download the HP Univeral Printing PCL 6 driver. # To findextract the .inf file, run 7-zip on the print driver .exe and go to the folder in Powershell and run this command: get-childitem *.inf* |copy-item -destination “C:examplefolder” Otherwise it’s hard to find the .inf files. $driversrc=”\10.1.1.21sysprepPrinter DriversApeosC2570ffac7070pcl6220420w636imlSoftwarePCLamd64Common 01FFSOBPCLA.inf”Write-Host “Reading from here: $driversrc”$driver = “FF Apeos C2570 PCL 6″$address = “10.1.1.31”$portnamesuffix = “_1″$portname = “$address$portnamesuffix”$name = “Admin Apeos C2570″$sleep = “3” # The invoke command can be added to specify a remote computer by adding -computername. You would need to copy the .inf file to the remote computer first though.# This script has it configured to run on the local computer that needs the printer.# The pnputil command imports the .inf file into the Windows driverstore.# The .inf driver file has to be physically on the local or remote computer that the printer is being installed on. Invoke-Command {pnputil.exe -a $driversrc } Add-PrinterDriver -Name $driver Start-Sleep $sleep #Get the infos of all printer$Printers = Get-WmiObject -Class Win32_Printer$PrinterPorts = Get-PrinterPort$PrinterName = $name # This creates the TCPIP printer port. It also will not use the annoying WSD port type that can cause problems.# WSD can be used by using a different command syntax though if needed. Try{Write-Verbose “Get the specified printer info.”$Printer = $PrinterPorts | Where{$_.Name -eq “$portname”} If (! $Printer){Write-Verbose “Adding printer port.”Add-PrinterPort -Name $portname -PrinterHostAddress $address Write-Host “$portname has been successfully added.”}Else{Write-Warning “Port already exists.”}}Catch{$ErrorMsg = $_.Exception.MessageWrite-Host $ErrorMsg -BackgroundColor Red} start-sleep $sleep Try{Write-Verbose “Get the specified printer info.”$Printer = $Printers | Where{$_.Name -eq “$PrinterName”} If (! $Printer){Write-Verbose “Adding printer.”Add-Printer -DriverName $driver -Name $name -PortName $portname Write-Host “$PrinterName has been successfully added.”}Else{Write-Warning “$PrinterName is already installed!.”}}Catch{$ErrorMsg = $_.Exception.MessageWrite-Host $ErrorMsg -BackgroundColor Red} Start-Sleep $sleep #Update the infos of all printer$Printers = Get-WmiObject -Class Win32_Printer Try{Write-Verbose “Get the specified printer info.”$Printer = $Printers | Where{$_.Name -eq “$PrinterName”} If($Printer){Write-Verbose “Setting the default printer.”$Printer.SetDefaultPrinter() | Out-Null Write-Host “$PrinterName has been successfully set as the default printer.”}Else{Write-Warning “Cannot find $PrinterName, can’t set it as the default printer.”}}Catch{$ErrorMsg = $_.Exception.MessageWrite-Host $ErrorMsg -BackgroundColor Red} Try{If($Printer){Write-Verbose “Setting printer defaults.”Set-PrintConfiguration -PrinterName $PrinterName -Color $false -DuplexingMode TwoSidedLongEdge | Out-NullWrite-Host “$PrinterName has printing defaults set.”}Else{Write-Warning “Cannot find the specified printer, can’t set printer defaults.”}}Catch{$ErrorMsg = $_.Exception.MessageWrite-Host $ErrorMsg -BackgroundColor Red} Get-PrintConfiguration -PrinterName $PrinterName# This prints a list of installed printers on the local computer. This proves the newly added printer works.Write-Warning “You must manually set the printer Output Color Preference to Black and White. Do it now!” get-printer |Out-Printer -Name $nameWrite-Host “If all went well a page should be printing out on the printer now.”When I run the commands manually, the error persists. This is the error:Add-PrinterDriver : The specified driver does not exist in the driver store. dd-PrinterDriver -Name “[Name]” -InfPath “[Path]” PS C:WindowsSystem32] At line:1 char:1 + Add-PrinterDriver -Name “[Name]” -InfPath “[Path]” + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (MSFT_PrinterDriver:ROOT/StandardCimv2/MSFT_PrinterDriver) [Add-PrinterDri ver], CimException + FullyQualifiedErrorId : HRESULT 0x80070705,Add-PrinterDriverI want to know if there is a reason that the driver is not getting found in the DriverStore despite my being able to locate it. And whether others have this issue, it appears as if it’s a windows issue. Read More