This year I wrote two blog posts about adding printer drivers and printers to Intune clients. Recently I repackaged these two into one package with some improvements. In this blog post, I will show how it looks now 🙂

Limitations
This blog post is for adding printers to Intune clients and is based on using local TCP/IP printer ports, and it does not work with printers shared on Windows Servers.
How the script works
The script will take the following steps:
- Import a printers.csv file containing all printers and their details. The CSV is formatted like this and also check the example one in the Script section: (The DriverName is present in the .inf files, make sure it matches and use a semi-column as the delimiter for all fields)
Name;DriverName;PortName;Comment;Location PrinterName;Exact DriverName as found in the .inf file;IP-Address or FQDN of the printer;Comment or description;Location of the printer
- Create a list of .inf files in the package directory, and you can add the driver directories in separate folders like this:
Canon HP Toshiba
- Install all the drivers from within those folders using the .inf files
- Add all the installed drivers to Windows using the Add-PrinterDriver cmdlet
- Add the printers using the fields from the CSV file to Windows using the Add-PrinterPort, Add-Printer, and Set-PrintConfiguration cmdlets. If it finds printer ports that were already present, it will remove the attached printer first and recreate it (Easy if you have an updated name or IP address for that port). You can edit the script to set the default Printer configuration. This example doesn’t print in color by default and prints on both sides of the paper.
The detection script for Intune will count the number of printers and check if they are all installed. If not, it will exit with code 1, which tells Intune to start the install.cmd.
Running the installation script
When running the Add_Printers.ps1 script, the output looks like this (It also logs all output to c:\windows\temp\printers.log using Start-Transcript)
Transcript started, output file is c:\windows\temp\printers.log [Install printer driver(s)] [1/3] Adding inf file C:\Users\WDAGUtilityAccount\Desktop\Adding Printer Drivers and Printers with Intune\Canon\CNP60MA64.INF [2/3] Adding inf file C:\Users\WDAGUtilityAccount\Desktop\Adding Printer Drivers and Printers with Intune\HP\hpcu250u.inf [3/3] Adding inf file C:\Users\WDAGUtilityAccount\Desktop\Adding Printer Drivers and Printers with Intune\TOSHIBA\esf6u.inf [Add printerdriver(s) to Windows] [1/3] Adding printerdriver TOSHIBA Universal Printer 2 [2/3] Adding printerdriver HP Universal Printing PCL 6 (v7.0.0) [3/3] Adding printerdriver Canon Generic Plus PCL6 [Add printer(s) to Windows] [1/3] Adding printer Contoso-General [2/3] Adding printer Contoso-HP [3/3] Adding printer Contoso-MFP Transcript stopped, output file is C:\windows\temp\printers.log
Running the detection script
Intune will run the detection script to see if all printers are installed. You can see the output in the AgentExector.log file in C:\ProgramData\Microsoft\IntuneManagementExtension\Logs :
Name ComputerName Type DriverName PortName Shared Published ---- ------------ ---- ---------- -------- ------ -------- Contoso-General Local TOSHIBA Universal Pri... Contoso-Gene... False False Contoso-HP Local HP Universal Printing... Contoso-HP False False Contoso-MFP Local Canon Generic Plus PC... Contoso-MFP False False (3) printers were found
If it can’t find all printers, it will remove/add everything with the values from the printers.csv list. By doing so, any change in the detection.ps1 script will start the installation so that changes in the printers.csv will be processed, making updating existing printers easier.
Note: Always update the detection.ps1 with the correct printer names when!
The scripts
Below are all the files needed for installation. Combine these with the printer folders into one folder and create a .intunewin file. Add the package to intune and use the detection.ps1 for the detection rule and the install.cmd and uninstall.cmd for install/uninstall and set it as System.
Add_Printers.ps1
Start-Transcript -Path c:\windows\temp\printers.log #Read printers.csv as input $Printers = Import-Csv .\printers.csv -Delimiter ';' #Add all printer drivers by scanning for the .inf files and installing them using pnputil.exe $infs = Get-ChildItem -Path . -Filter "*.inf" -Recurse -ErrorAction SilentlyContinue | Select-Object -ExpandProperty Fullname $totalnumberofinfs = $infs.Count $currentnumber = 1 Write-Host ("[Install printer driver(s)]`n") -ForegroundColor Green Foreach ($inf in $infs) { Write-Host ("[{0}/{1}] Adding inf file {2}" -f $currentnumber, $totalnumberofinfs, $inf) -ForegroundColor Green try { c:\windows\sysnative\Pnputil.exe /a $inf | Out-Null } catch { try { c:\windows\system32\Pnputil.exe /a $inf | Out-Null } catch { C:\Windows\SysWOW64\pnputil.exe /a $inf | Out-Null } } $currentnumber++ } #Add all installed drivers to Windows using the CSV list for the correct names $totalnumberofdrivers = ($printers.drivername | Select-Object -Unique).count $currentnumber = 1 Write-Host ("`n[Add printerdriver(s) to Windows]") -ForegroundColor Green foreach ($driver in $printers.drivername | Select-Object -Unique) { Write-Host ("[{0}/{1}] Adding printerdriver {2}" -f $currentnumber, $totalnumberofdrivers, $driver) -ForegroundColor Green Add-PrinterDriver -Name $driver $currentnumber++ } #Loop through all printers in the csv-file and add the Printer port, the printer and associate it with the port and set the color options to 0 which is black and white (1 = automatic and 2 = color) $totalnumberofprinters = $Printers.Count $currentnumber = 1 Write-Host ("`n[Add printer(s) to Windows]") -ForegroundColor Green foreach ($printer in $printers) { Write-Host ("[{0}/{1}] Adding printer {2}" -f $currentnumber, $totalnumberofprinters, $printer.Name) -ForegroundColor Green #Set options for adding printers and their ports $PrinterAddOptions = @{ ComputerName = $env:COMPUTERNAME Comment = $Printer.Comment DriverName = $Printer.DriverName Location = $Printer.Location Name = $Printer.Name PortName = $Printer.Name } $PrinterConfigOptions = @{ Color = $False DuplexingMode = 'TwoSidedLongEdge' PrinterName = $Printer.Name } $PrinterPortOptions = @{ ComputerName = $env:COMPUTERNAME Name = $Printer.Name PrinterHostAddress = $Printer.PortName PortNumber = '9100' } #Add Printerport, remove existing one and the corresponding printer if it already exists if (Get-PrinterPort -ComputerName $env:COMPUTERNAME | Where-Object Name -EQ $printer.Name) { Write-Warning ("Port for Printer {0} already exists, removing existing port and printer first" -f $printer.Name) Remove-Printer -Name $printer.Name -ComputerName $env:COMPUTERNAME -Confirm:$false -ErrorAction SilentlyContinue Start-Sleep -Seconds 10 Remove-PrinterPort -Name $printer.Name -ComputerName $env:COMPUTERNAME -Confirm:$false } #Add printer and configure it with the required options Add-PrinterPort @PrinterPortOptions Add-Printer @PrinterAddOptions -ErrorAction SilentlyContinue Set-PrintConfiguration @PrinterConfigOptions $currentnumber++ } Stop-Transcript
Detection.ps1
$printers = @( 'Contoso-General' 'Contoso-HP' 'Contoso-MFP' ) #Check every printer if it's installed $numberofprintersfound = 0 foreach ($printer in $printers) { try { Get-Printer -Name $printer -ErrorAction Stop $numberofprintersfound++ } catch { "Printer $($printer) not found" } } #If all printers are installed, exit 0 if ($numberofprintersfound -eq $printers.count) { write-host "($numberofprintersfound) printers were found" exit 0 } else { write-host "Not all $($printers.count) printers were found" exit 1 }
Install.cmd
powershell.exe -executionpolicy bypass -file .\add_printers.ps1
Printers.csv
Name;DriverName;PortName;Comment;Location Contoso-General;TOSHIBA Universal Printer 2;192.1.2.3;Contoso;Hallway Contoso-HP;HP Universal Printing PCL 6 (v7.0.0);192.4.5.6;HR;HR Office Contoso-MFP;Canon Generic Plus PCL6;192.7.8.9;MFP;Finance Office
Remove_Printers.ps1
Start-Transcript -Path c:\windows\temp\remove_printers.log #Read printers.csv as input $Printers = Import-Csv .\printers.csv -Delimiter ';' #Loop through all printers in the csv-file and remove the printers listed foreach ($printer in $printers) { #Set options $PrinterRemoveOptions = @{ Confirm = $false Name = $Printer.Name } $PrinterPortRemoveOptions = @{ Confirm = $false Computername = $env:COMPUTERNAME Name = $Printer.Name } #Remove printers and their ports Remove-Printer @PrinterRemoveOptions Start-Sleep -Seconds 10 Remove-PrinterPort @PrinterPortRemoveOptions } #Remove drivers from the system foreach ($driver in $printers.drivername | Select-Object -Unique) { $PrinterDriverRemoveOptions = @{ Confirm = $false Computername = $env:COMPUTERNAME Name = $driver RemoveFromDriverStore = $true } Remove-PrinterDriver @PrinterDriverRemoveOptions } Stop-Transcript
Uninstall.cmd
powershell.exe -executionpolicy bypass -file .\remove_printers.ps1
Download the script(s) from GitHub here
Adding the package to Intune
Create a .intunewin package
Below are the steps for creating a .intunewin package which you can add to Intune:
- Create a folder, for example, C:\Temp\Printers, and copy all the above scripts and the driver directories needed. (Make sure to include all printer installation files, just the .inf file is insufficient.) In my case, the contents of C:\Temp\Printers look like this:
Canon HP TOSHIBA Add_Printers.ps1 Detection.ps1 install.cmd printers.csv Remove_Printers.ps1 uninstall.cmd
- Start intunewinapputil.exe (Download from here) and enter this
Please specify the source folder: C:\Temp\Printers C:\Temp\Printers Please specify the setup file: install.cmd Please specify the output folder: C:\Temp Do you want to specify catalog folder (Y/N)?N
- After pressing Enter, the intunewinapputil.exe will create an install.intunewin file in C:\Temp
INFO File 'C:\Temp\install.intunewin' has been generated successfully [=================================================] 100% INFO Done!!!
Note: You can also create the .intunewin package in a one-liner:
IntuneWinAppUtil -c C:\Temp\Printers -s install.cmd -o C:\Temp
Uploading the .intunewin package
Below are the steps needed to add the package to Intune:
- Go to Windows – Microsoft Endpoint Manager admin center
- Select Add, select Windows app (Win32) from the pulldown menu, and click Select.
- Click on Select app package file, click on the folder icon, select the C:\Temp\install.intunewin file, choose Open, and click on Ok.
- Enter “Printers” as Name, for example.
- Select Edit Description and change Description to “Install printer drivers and add printers,” for example, and click Ok.
- Enter “PowerShellisfun” as Publisher, for example 😉
- Enter “1.0” as App Version
- Select Next
- Enter “install.cmd” as Install command and “uninstall.cmd” as Uninstall command.
- Make sure System is selected as Install behavior (Drivers and printers need to be added with sufficient permissions)
- Change Device restart behavior to No specific action
- Select Next
- Select 32-bit and 64-bit as Operating system architecture.
- Select Windows 10 20H1 as Minimum operating system (Or lower/higher if needed)
- Select Next
- Select Use a custom detection script as Rules format
- Click on Select a file and select C:\Temp\Printers\Detection.ps1 and choose Open
- Select Next
- Select Next on the Dependencies screen.
- Select Next on the Supercedence (preview) screen.
- Select Add group in the Required or Available for enrolled Devices section, browse, and select the desired group.
- Select Next
- Select Create
Note: First, deploy it to a test group. Check the installation status in the just created App and in C:\Windows\Temp\Printers.log if needed. There’s also a remove_printers.log for the uninstall.
Pingback: Blog post – Adding printer drivers and printers using Intune – 247 TECH
Pingback: Intune Newsletter - 9th December 2022 - Andrew Taylor
Harm, when making the package, which file do I specify as the setup file?
If you have all the .cmd and .ps1 files in the directory including the subfolders with the drivers, you can specify install.cmd as the setup file. When configuring the Win32 app in Intune, you can also specify that one as the install command
Harm, this is exactly what I’m looking for! However, i’m a complete novice :/ . How do I exact the correct info for printers.csv? thank you in advance!
The CSV is made from a few things:
“Name”,”DriverName”,”PortName”,”Comment”,”Location”
“Contoso-General”,”TOSHIBA Universal Printer 2″,”192.1.2.3″,”Contoso”,”Hallway”
The first part is the printer’s name, which is how the user will see it in Windows. The second part is the driver’s name. When you have the printer installed on a system, you will see this in your printer options. The third part is the address or fqdn name of the printer. The fourth part is the comment that the user can see and use to identify the printer, together with the fifth part, which tells them the location.
You have to fill these to your liking. It depends on what printers you want to install on the client.
powershell.exe : At C:\temp\test2\Scripts\add_printers.ps1:8 char:72
At line:1 char:1
+ powershell.exe -executionpolicy bypass -file add_printers.ps1
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (At C:\temp\test…s.ps1:8 char:72:String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
… )]
n") -Foreg ...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Unexpected token 'n" class="EnlighterJSRAW">n"' in expression or statement.
At C:\temp\test2\Scripts\add_printers.ps1:8 char:72
... ("[Install printer driver(s)]<code data-enlighter-language="n" class ...
~
Missing closing ')' in expression.
At C:\temp\test2\Scripts\add_printers.ps1:8 char:100
... ]
n") -Foregr ...
~
Unexpected token ')' in expression or statement.
CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
FullyQualifiedErrorId : UnexpectedToken
This is because ot the Enlighter code plugin 🙁 Copying it like this from the blog post doesn’t seem to work, it adds stuff to it 🙁 Best thing is to go to the Github page (Link below the post) and copy/paste/download it from there
It was a setting in the plugin, the developer of Enlighter pointed me that that. Thanks https://github.com/AndiDittrich !
Would you mind including some screenshots for how this was added as a Win32 app in Intune?
I added a step-by-step how-to to the blog post now 🙂
Hi there again, it’s also unclear how you generated the intunewin file. There’s not really an executable here, right? I tried using only the -c and -o switches but it still requires a -s to complete.
Correct, there’s no executable but you can point to the install.cmd file, I added the steps to the blog post just now 🙂
Is this supposed to work on AADJ Autopilot devices ?
Yes, the script adds drivers, printer ports and local printers to the device. Are you running into issues?
Hi Harm,
I’ve deployed the package on a group test. A small part of the computers have printers deployed properly. A lot of the computers have no printers deployed.
Also the install status is at Failed for all computers.
I’ve tried first to assign as Required then as Available for enrolled devices on the group test.
The result is the same.
Windows version on all PCs is higher than Windows 10 20H1, as setup in Intune.
Can you please advise on this ? Thanks !
Could you post the contents of the log file that is in c:\windows\temp? That should list the things of the installation process
The C:\windows\temp is empty.
What should be the name of the log file or folder ?
It’s the file which is in the first line of the Add_Printers.ps1 script, printers.log
Sorry I found it. The content is :
Début de la transcription Windows PowerShell
Heure de début : 20230309175524
Nom d’utilisateur : WORKGROUP\Système
Utilisateur runAs : WORKGROUP\Système
Nom de la configuration :
Ordinateur : LAPTOP-R8FLJPF1 (Microsoft Windows NT 10.0.19045.0)
Application hôte : powershell.exe -executionpolicy bypass -file .\add_printers.ps1
ID de processus : 21204
PSVersion: 5.1.19041.2364
PSEdition: Desktop
PSCompatibleVersions: 1.0, 2.0, 3.0, 4.0, 5.0, 5.1.19041.2364
BuildVersion: 10.0.19041.2364
CLRVersion: 4.0.30319.42000
WSManStackVersion: 3.0
PSRemotingProtocolVersion: 2.3
SerializationVersion: 1.1.0.1
Transcription démarrée, le fichier de sortie est c:\windows\temp\printers.log
[Install printer driver(s)]
[1/1] Adding inf file C:\Windows\IMECache\e812789a-b68b-4f4a-b22b-a6fc2c21dd64_1\Canon\CNP60MA64.INF
[Add printerdriver(s) to Windows]
[1/1] Adding printerdriver Canon Generic Plus PCL6
Add-PrinterDriver : Le pilote spécifié n’existe pas dans le magasin de pilotes.
Au caractère C:\Windows\IMECache\e812789a-b68b-4f4a-b22b-a6fc2c21dd64_1\add_printers.ps1:33 : 5
+ Add-PrinterDriver -Name $driver
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (MSFT_PrinterDriver:ROOT/StandardCimv2/MSFT_PrinterDriver)
[Add-PrinterDriver], CimException
+ FullyQualifiedErrorId : HRESULT 0x80070705,Add-PrinterDriver
Add-PrinterDriver : Le pilote spécifié n’existe pas dans le magasin de pilotes.
Au caractère C:\Windows\IMECache\e812789a-b68b-4f4a-b22b-a6fc2c21dd64_1\add_printers.ps1:33 : 5
+ Add-PrinterDriver -Name $driver
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (MSFT_PrinterDriver:ROOT/StandardCimv2/MSFT_PrinterDriver) [Add-PrinterDri
ver], CimException
+ FullyQualifiedErrorId : HRESULT 0x80070705,Add-PrinterDriver
[Add printer(s) to Windows]
[1/3] Adding printer Printer R2 – Paris office
Set-PrintConfiguration : L’imprimante spécifiée est introuvable.
Au caractère C:\Windows\IMECache\e812789a-b68b-4f4a-b22b-a6fc2c21dd64_1\add_printers.ps1:78 : 5
+ Set-PrintConfiguration @PrinterConfigOptions
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (MSFT_PrinterConfiguration:ROOT/StandardCi…erConfiguration)
[Set-PrintConfiguration], CimException
+ FullyQualifiedErrorId : HRESULT 0x80070709,Set-PrintConfiguration
Set-PrintConfiguration : L’imprimante spécifiée est introuvable.
Au caractère C:\Windows\IMECache\e812789a-b68b-4f4a-b22b-a6fc2c21dd64_1\add_printers.ps1:78 : 5
+ Set-PrintConfiguration @PrinterConfigOptions
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (MSFT_PrinterConfiguration:ROOT/StandardCi…erConfiguration) [Set-PrintCo
nfiguration], CimException
+ FullyQualifiedErrorId : HRESULT 0x80070709,Set-PrintConfiguration
[2/3] Adding printer Printer R3 – Paris office
Set-PrintConfiguration : L’imprimante spécifiée est introuvable.
Au caractère C:\Windows\IMECache\e812789a-b68b-4f4a-b22b-a6fc2c21dd64_1\add_printers.ps1:78 : 5
+ Set-PrintConfiguration @PrinterConfigOptions
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (MSFT_PrinterConfiguration:ROOT/StandardCi…erConfiguration)
[Set-PrintConfiguration], CimException
+ FullyQualifiedErrorId : HRESULT 0x80070709,Set-PrintConfiguration
Set-PrintConfiguration : L’imprimante spécifiée est introuvable.
Au caractère C:\Windows\IMECache\e812789a-b68b-4f4a-b22b-a6fc2c21dd64_1\add_printers.ps1:78 : 5
+ Set-PrintConfiguration @PrinterConfigOptions
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (MSFT_PrinterConfiguration:ROOT/StandardCi…erConfiguration) [Set-PrintCo
nfiguration], CimException
+ FullyQualifiedErrorId : HRESULT 0x80070709,Set-PrintConfiguration
[3/3] Adding printer Printer R4 – Paris office
Set-PrintConfiguration : L’imprimante spécifiée est introuvable.
Au caractère C:\Windows\IMECache\e812789a-b68b-4f4a-b22b-a6fc2c21dd64_1\add_printers.ps1:78 : 5
+ Set-PrintConfiguration @PrinterConfigOptions
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (MSFT_PrinterConfiguration:ROOT/StandardCi…erConfiguration)
[Set-PrintConfiguration], CimException
+ FullyQualifiedErrorId : HRESULT 0x80070709,Set-PrintConfiguration
Set-PrintConfiguration : L’imprimante spécifiée est introuvable.
Au caractère C:\Windows\IMECache\e812789a-b68b-4f4a-b22b-a6fc2c21dd64_1\add_printers.ps1:78 : 5
+ Set-PrintConfiguration @PrinterConfigOptions
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (MSFT_PrinterConfiguration:ROOT/StandardCi…erConfiguration) [Set-PrintCo
nfiguration], CimException
+ FullyQualifiedErrorId : HRESULT 0x80070709,Set-PrintConfiguration
Fin de la transcription Windows PowerShell
Heure de fin : 20230309175527
“1/1] Adding inf file C:\Windows\IMECache\e812789a-b68b-4f4a-b22b-a6fc2c21dd64_1\Canon\CNP60MA64. INF
[Add printerdriver(s) to Windows] [1/1]
Adding printerdriver Canon Generic Plus PCL6
Add-PrinterDriver: The specified driver does not exist in the driver store.
To the character C:\Windows\IMECache\e812789a-b68b-4f4a-b22b-a6fc2c21dd64_1\add_printers.ps1:33 : 5 + Add-PrinterDriver -Name $driver + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo: NotSpecified: (MSFT_PrinterDriver:ROOT/StandardCimv2/MSFT_PrinterDriver)
[Add-PrinterDriver], CimException
Add-PrinterDriver: The specified driver does not exist in the driver store.
To the character C:\Windows\IMECache\e812789a-b68b-4f4a-b22b-a6fc2c21dd64_1\add_printers.ps1:33 : 5 + Add-PrinterDriver -Name $driver + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo: NotSpecified: (MSFT_PrinterDriver:ROOT/StandardCimv2/MSFT_PrinterDriver) [Add-PrinterDri
ver], CimException”
Are you sure that the driver name is correct? What is in the CNP60MA64. INF? Does it say ‘Canon Generic Plus PCL6’?
If you open Print Management, and open Custom Filters, All Drivers? Is that driver name there?
CNP60MA64.INF is the filename for the Canon Generic Plus PCL6 driver. Which name should I write in the printers.csv ?
I can’t find Print Management but I did a Get-PrinterDriver and the driver is not there.
Does the package install the driver ?
The Get-PrinterDriver cmdlet shows installed drivers, so it seems the driver is not installed. You should specify that name in the second column of the CSV like in the example in the post above. The package installs the all printerdrivers that it can find in the package, it scans the subdirectories for .inf files and installs those. Somehow the .inf file is installed (and the driver) if I check your log output. Seems like formatting is wrong in your CSV perhaps?
Could you share your files which you used to create the package with? You can email me on harm.veenstra@gmail.com with a download link
Thanks for emailing it, glad that I could help out with the driver installation!
Hi Harm,
Thank you for the detailed instructions on how to get this setup. I am having the same issues with Toshiba drives. In the CSV i have tried the name Toshiba Universal Driver 2 and the driver file name and keep getting the same error. Any help ?
Could you share the csv and the link to the driver that you use?
Hi Harm … How can I pre-determine the name of the driver that is embedded in the .INF file? For example , the HP Universal Print Driver has 12 .inf files, which one is used to determine the eventual drive name stored in the driverstore
I usually download and extract a specific printer driver, then I start my Windows Sandbox (Or another VM or your computer), go to Settings, Bluetooth & Devices, Printers and Scanners, and Print Server properties. Go to the Drivers tab, choose Add and point to the extracted files. In the case of the HP Universal Printer driver, I just tested it, and it always shows two when selecting a .inf file: HP Universal Printing PCL6 and HP Universal Printing PCL6 (v7.0.1). I would go for the one with v7.0.1 in the description so that you know the version.
Most of the .inf files don’t have the Printer driver’s name. Some do but then for a specific (Non-Universal?) driver. The hpcu255u.inf file has the information and is the biggest .inf file, but I am unsure if that’s the reason 😉
The other two examples in my blog post, Toshiba and Canon don’t have that many .inf files… Just one 🙂 It’s an HP thing? Test functionality before choosing between the PCL6 and the PCL6 (v7.0.1). Not sure if there’s a difference between them…
This is an incredible post. Very well written and easy to follow. We have been looking for a printer deployment solution for our small clients using Intune without paying for PrinterLogic or something similar. Thanks for writing this!
One thing to add, if you get an error message when trying to install the printer driver (like ‘requested file not found’), it’s probably because the driverfile.inf file is looking for other files to complete the driver installation. Most of the time, just the inf file is not sufficient. For example, for our Ricoh copier, once I copied the entire contents that the big exe drive file extracts to the folder, the driver install completed without issue.
Thank you 😊 yes, it’s a simple solution to install printers that doesn’t require any additional subscriptions 😅
And yes, download and extract the complete driver package and pnputil will install all drivers in the package for you
Great Stuff, Really useful well crafted scripts. Now our T1 techs can build out Intune packages without many issues. Also Printers are evil so this really helps keep the gates of hell shut !
😁 True, true
Hello Harm!
Great job, helped a lot!
I tested the installation, I was successful. Then I tested the removal and I was also successful.
Thank you very much!
Great to hear, no problem 😊
First, Harm this is AWESOME! Thanks a ton.
Hi Eduardohss,
We have been successful with the installation but not successful with the removal. Can you let me know how you assigned the app in Intune? We’ve tried adding a printername group to the required section and all devices in the uninstall section. This way if the device is in the printername group it gets the printer installed but if it’s not then it’s in the all devices group which then it should get removed (but doesn’t). I’ve tried removing the printername group from the required section and adding it to the uninstall section but then nothing happens. Just trying to get a feel how you did it so I can replicate the removal of the printer successfully.
Thanks in advance,
Dan
Thanks for the reply 😊 @eduardohss , if you read this… Can you reply, if not.. I can answer too 😅
Hi Harm,
Installation was successful; However, I’m getting the PortName the same as the PrinterName instead of the IP address. any tips?
That is correct, it’s the same. There’s one entry in the csv file for that (The portname column). I used that to be the name and target ip-address. How does your CSV look like, could you give an example line?
Hi Harm,
“Name”,”DriverName”,”PortName”,”Comment”,”Location”
“GDC-C4476″,”HP C4476 PCL 6″,”10.10.10.10″,”GDC”,”UK”
In the printer properties > ports > it shows “GDC-C4476” instead of the IP address. but when i click on “configure port” it shows the correct IP address in the “Printer name or IP address” and it’s working perfectly in my test. I think this fine to have different entries in Port Name & Printer Name or IP Address 🙂
Ah, yes 😅 I used the name of the printer for the port name 😊 perfect 👌
Harm,
Huge credit to you for putting this awesome, easy to follow, post together for something I think ALOT of people will benefit from.
The printers install just fine but I can’t get them to uninstall. Can you point me where I could start troubleshooting this?
I have the app assignments as follows:
Kyocera AAD group in the Required section.
“All Devices” set in the Uninstall section
My expectation is if a device is in the Kyocera group then the printer will get installed. If it is not in the Kyocera group then it will uninstall the printer.
My testing results are: I put the device in the Kyocera group and the printer is installed. When I remove the device from the Kyocera group the printer does not get removed.
I tried modifying the app assignment such that there is NO required or assigned entries but only the Uninstall section has Kyocera and I put the device back in that group. The results still did not remove the printer.
FYI, I delete the printer.log file between each test and in the last test (only the uninstall section has Kyocera) the printer.log file never gets generated.
Any help would be much appreciated.
Dan
Hmmm… Uninstall takes precedence, so that’s not correct… But if you removed the device from the Kyocera group, it should be uninstalled.
There was no logging in the uninstall script, I just added it now to the blog post and in GitHub. When the uninstall script runs, it will leave a remove_printers.log file in c:\windows\temp now. So, update your package and let me know 😉
Wow, thanks for the rapid response..
Here’s the results from the remove_printer.log files (by the way, the printer actually was removed this time, not the driver though. I did nothing else but rebuild the package with the updated removeprinter.ps1 contents)
Windows PowerShell transcript start
Start time: 20230405161830
Username: WORKGROUP\SYSTEM
RunAs User: WORKGROUP\SYSTEM
Configuration Name:
Machine: DESKTOP-RC419LH (Microsoft Windows NT 10.0.19044.0)
Host Application: powershell.exe -executionpolicy bypass -file .\remove_printers.ps1
Process ID: 9652
PSVersion: 5.1.19041.2673
PSEdition: Desktop
PSCompatibleVersions: 1.0, 2.0, 3.0, 4.0, 5.0, 5.1.19041.2673
BuildVersion: 10.0.19041.2673
CLRVersion: 4.0.30319.42000
WSManStackVersion: 3.0
PSRemotingProtocolVersion: 2.3
SerializationVersion: 1.1.0.1
Transcript started, output file is c:\windows\temp\remove_printers.log
Remove-PrinterDriver : An error occurred while performing the specified operation. See the error details for more
information.
At C:\Windows\IMECache\42c73103-a8cf-420c-a53f-7cdcfd955690_7\remove_printers.ps1:34 char:5
+ Remove-PrinterDriver @PrinterDriverRemoveOptions
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (MSFT_PrinterDri… “Windows x64”):ROOT/StandardCimv2/MSFT_PrinterDriver)
[Remove-PrinterDriver], CimException
+ FullyQualifiedErrorId : HRESULT 0x80070bc7,Remove-PrinterDriver
Remove-PrinterDriver : An error occurred while performing the specified operation. See the error details for more
information.
At C:\Windows\IMECache\42c73103-a8cf-420c-a53f-7cdcfd955690_7\remove_printers.ps1:34 char:5
+ Remove-PrinterDriver @PrinterDriverRemoveOptions
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (MSFT_PrinterDri… “Windows x64”):ROOT/StandardCimv2/MSFT_PrinterDriver)
[Remove-PrinterDriver], CimException
+ FullyQualifiedErrorId : HRESULT 0x80070bc7,Remove-PrinterDriver
Windows PowerShell transcript end
End time: 20230405161844
Ok, it should remove both… So progress, but not completely…. Perhaps the Kyocera driver is stubborn? Perhaps you can zip and share your script an driver directories so that I can test it tomorrow?
It looks like due to printer drivers indeed. I was able to uninstall with HP printer from Intune but NOT with Fujifilm printer.
HP – it removes the printer name, drivers & portname
Fujifilm – it removes only the printer name
Also, the black & white and color options work on HP, but with Fujifilm it’s always in color, it doesn’t matter if you set the color option to 0, 1 or 2 in the script.
Ah, ok… Can’t test all drivers of course and some drivers are badly developed. And it could be that drivers don’t use the default options…
Printers… They are never fun 😅
Not sure if you have come across this but the intune package only works if the user is local admin
Unless I have done something wrong
The work around is –
I have created two Intune packages one for the driver install that runs as system and one that runs as user to add the printer
Linking the two package by dependency
If you know a way to do this without separate packages that would be great
I install the whole package as SYSTEM, not as a user 😅 After installation, the printers are available for all users on that system. (I updated the blog post part about adding it to Intune to reflect that now)
Harm, I’m ok with having the driver hang around. I don’t expect you to troubleshoot that part of it. Thanks again for the solution AND the support!
😊 No problem!
Wow, this post is so helpful. Thx Harm!
I deployed the app as an available app in intune. When I install it via the company portal on a device with a non-admin user.I get the warning that the app could not install.
But the printers are installed.
Any idea how I can fix this?
Thanks☺️ The installation behavior should be system for this to work, what do you have configured?
Yes I used the system install behavior.
I have the Windows security baseline and Microsoft defender security baseline enabled. Maybe this is causing a conflict? I will do further testing and keep you updated.
Install command – install.cmd
Uninstall command – uninstall.cmd
Install behavior – System
Device restart behavior – No specific action
Return codes –
0 Success
1707 Success
3010 Soft reboot
1641 Hard reboot
1618 Retry
Ok, curious! I personally install it as required and don’t make it available, hope that works too!
FYI, the security baselines do not cause rhe warning. I will configure the app as required.
Luckily it’s not the security baseline 🙂 Let me know how it works out
Unfortunatelly it keeps saying the install failed (100% failed). But the printers are installed on the devices. If I run the detection script it gives me the correct printer.
Error in Intune: “The application was not detected after installation completed successfully (0x87D1041C)”
Could you share the whole package directory with me? You can send a download link to harm.veenstra@powershellisfun.com
Thank you!
I shared the package
Will take a look tomorrow or this weekend, national holiday today 😊
Thx, en een leuke koningsdag gewenst!
Supersized Kingsday in aquabest 😁
Found the isse 🙂 In the detecion.ps1 you should change
$printers = @(
‘KONICA MINOLTA C364SeriesPCL’
)
to
$printers = @(
‘KONICA MINOLTA C364’
)
The displayname of the printer should be listed there instead of the drivername, could you check if this works out for you?
Nice write up, Harm! I have one question though I have some printers added through Universal Print as cloud printers. The script doesn’t rename/replace those? Any idea how to modify it that way?
Ah, that’s something I didn’t have the chance to test or look at… When you unassign printers in Universal Print, doesn’t it remove the printers for those users?
Hi Harm,
Great job on the scripts. It has been a pain deploying printers after the printnightmare.
The printers install but Intune shows a failure. This is probably related to a network printer that has been installed prior and the Port IP is the same. We get this error:
Transcript started, output file is c:\windows\temp\printers.log
[Install printer driver(s)]
[1/1] Adding inf file C:\WINDOWS\IMECache\6dfc1758-caf6-47a6-91c7-192be7906de4_1\Ricoh\disk1\oemsetup.inf
[Add printerdriver(s) to Windows]
[1/1] Adding printerdriver RICOH MP C4504ex PCL 6
[Add printer(s) to Windows]
[1/] Adding printer RICOH MP C4504ex
WARNING: Port for Printer RICOH MP C4504ex already exists, removing existing port and printer first
Windows PowerShell transcript end
End time: 20230426141002
What would be the best way to address this?
Hmm… Could you add this above the part where it checks for existing printer ports?
Remove-PrinterPort -Name Nameofpriorinstalledprinterport -ComputerName $env:COMPUTERNAME -Confirm:$false
I’ve added the line here with the IP of the port
#Add Printerport, remove existing one and the corresponding printer if it already exists
Remove-PrinterPort -Name 10.0.3.94 -ComputerName $env:COMPUTERNAME -Confirm:$false
I get below in the output.
Transcript started, output file is c:\windows\temp\printers.log
[Install printer driver(s)]
[1/1] Adding inf file C:\WINDOWS\IMECache\df393782-b19c-44b7-bd9a-571088ea57ab_1\Ricoh\disk1\oemsetup.inf
[Add printerdriver(s) to Windows]
[1/1] Adding printerdriver RICOH MP C4504ex PCL 6
[Add printer(s) to Windows]
[1/] Adding printer RICOH MP C4504ex
Remove-PrinterPort : No MSFT_PrinterPort objects found with property ‘Name’ equal to ‘10.0.3.94’. Verify the value of
the property and retry.
At C:\WINDOWS\IMECache\df393782-b19c-44b7-bd9a-571088ea57ab_1\add_printers.ps1:68 char:2
+ Remove-PrinterPort -Name 10.0.3.94 -ComputerName $env:COMPUTERNAM …
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (10.0.3.94:String) [Remove-PrinterPort], CimJobException
+ FullyQualifiedErrorId : CmdletizationQuery_NotFound_Name,Remove-PrinterPort
Remove-PrinterPort : No MSFT_PrinterPort objects found with property ‘Name’ equal to ‘10.0.3.94’. Verify the value of
the property and retry.
At C:\WINDOWS\IMECache\df393782-b19c-44b7-bd9a-571088ea57ab_1\add_printers.ps1:68 char:2
+ Remove-PrinterPort -Name 10.0.3.94 -ComputerName $env:COMPUTERNAM …
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (10.0.3.94:String) [Remove-PrinterPort], CimJobException
+ FullyQualifiedErrorId : CmdletizationQuery_NotFound_Name,Remove-PrinterPort
WARNING: Port for Printer RICOH MP C4504ex already exists, removing existing port and printer first
Windows PowerShell transcript end
End time: 20230427122753
What’s interesting is that now Intune shows the install as successful.
Ok 😅 you could check the name on one of the systems by running get-printerport or checking the properties of the printer.. Weird…
Hello Harm, when i executed the script as is from github, i encounterd the following errors: “[Install printer driver(s)]
[1/3] Adding inf file C:\Temp\Powershellisfun-main\Adding Printer Drivers and Printers with Intune\Canon\CNP60MA64.INF
[2/3] Adding inf file C:\Temp\Powershellisfun-main\Adding Printer Drivers and Printers with Intune\HP\hpcu250u.inf
[3/3] Adding inf file C:\Temp\Powershellisfun-main\Adding Printer Drivers and Printers with Intune\TOSHIBA\esf6u.inf
[Add printerdriver(s) to Windows]
[Add printer(s) to Windows]
[1/3] Adding printer
Add-PrinterPort : Cannot validate argument on parameter ‘Name’. The argument is null or empty. Provide an argument that
is not null or empty, and then try the command again.
At C:\Temp\Powershellisfun-main\Adding Printer Drivers and Printers with Intune\add_printers.ps1:76 char:21
+ Add-PrinterPort @PrinterPortOptions
+ ~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (:) [Add-PrinterPort], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,Add-PrinterPort
Add-Printer : Cannot bind argument to parameter ‘Name’ because it is an empty string.
At C:\Temp\Powershellisfun-main\Adding Printer Drivers and Printers with Intune\add_printers.ps1:77 char:17
+ Add-Printer @PrinterAddOptions -ErrorAction SilentlyContinue
+ ~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (:) [Add-Printer], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationErrorEmptyStringNotAllowed,Add-Printer
Set-PrintConfiguration : Cannot validate argument on parameter ‘PrinterName’. The argument is null or empty. Provide an
argument that is not null or empty, and then try the command again.
At C:\Temp\Powershellisfun-main\Adding Printer Drivers and Printers with Intune\add_printers.ps1:78 char:28
+ Set-PrintConfiguration @PrinterConfigOptions
+ ~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (:) [Set-PrintConfiguration], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,Set-PrintConfiguration
[2/3] Adding printer
Add-PrinterPort : Cannot validate argument on parameter ‘Name’. The argument is null or empty. Provide an argument that
is not null or empty, and then try the command again.
At C:\Temp\Powershellisfun-main\Adding Printer Drivers and Printers with Intune\add_printers.ps1:76 char:21
+ Add-PrinterPort @PrinterPortOptions
+ ~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (:) [Add-PrinterPort], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,Add-PrinterPort
Add-Printer : Cannot bind argument to parameter ‘Name’ because it is an empty string.
At C:\Temp\Powershellisfun-main\Adding Printer Drivers and Printers with Intune\add_printers.ps1:77 char:17
+ Add-Printer @PrinterAddOptions -ErrorAction SilentlyContinue
+ ~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (:) [Add-Printer], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationErrorEmptyStringNotAllowed,Add-Printer
Set-PrintConfiguration : Cannot validate argument on parameter ‘PrinterName’. The argument is null or empty. Provide an
argument that is not null or empty, and then try the command again.
At C:\Temp\Powershellisfun-main\Adding Printer Drivers and Printers with Intune\add_printers.ps1:78 char:28
+ Set-PrintConfiguration @PrinterConfigOptions
+ ~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (:) [Set-PrintConfiguration], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,Set-PrintConfiguration
[3/3] Adding printer
Add-PrinterPort : Cannot validate argument on parameter ‘Name’. The argument is null or empty. Provide an argument that
is not null or empty, and then try the command again.
At C:\Temp\Powershellisfun-main\Adding Printer Drivers and Printers with Intune\add_printers.ps1:76 char:21
+ Add-PrinterPort @PrinterPortOptions
+ ~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (:) [Add-PrinterPort], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,Add-PrinterPort
Add-Printer : Cannot bind argument to parameter ‘Name’ because it is an empty string.
At C:\Temp\Powershellisfun-main\Adding Printer Drivers and Printers with Intune\add_printers.ps1:77 char:17
+ Add-Printer @PrinterAddOptions -ErrorAction SilentlyContinue
+ ~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (:) [Add-Printer], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationErrorEmptyStringNotAllowed,Add-Printer
Set-PrintConfiguration : Cannot validate argument on parameter ‘PrinterName’. The argument is null or empty. Provide an
argument that is not null or empty, and then try the command again.
At C:\Temp\Powershellisfun-main\Adding Printer Drivers and Printers with Intune\add_printers.ps1:78 char:28
+ Set-PrintConfiguration @PrinterConfigOptions
+ ~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (:) [Set-PrintConfiguration], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,Set-PrintConfiguration
Transcript stopped, output file is C:\windows\temp\printers.log”
Can you tell me what could be the cause of this error?
Regards, Ronald Popken
I guess the .csv file is not correctly formatted? You can email it to me to the address in the Contact tab so that I can check it for you.
I updates the blogpost with a different CSV formatting (Delimiter change), you can download the updated script and try again?
Hello,
I am getting an error: Add-PrinterDriver : Installation of the specified driver was blocked.
I can’t determine what setting is causing it to be blocked. Any ideas?
I’m not sure if my comments are going through or not…
I keep getting this error message
Add-PrinterDriver: Installation of the specified driver was blocked.
I’m not sure how to go about fixing this. Any idea what is blocking the driver installation? These devices are running Windows 11 SE.
Thank you!
I have to approve comments from new users before they show up here 🙂 #SpamBlocking But Windows 11 SE has some limitations, not sure if this is one of them. (No personal experience) If you add go to Printers and Scanners, Print Server Properties, Select Drivers tab, select Add and point to the driver directory… Does it install then?
Thanks for the tip. The driver was incompatible with Windows 11 I guess. I switched to a v4 universal driver and it installed no problem.
After I install the printer and open printer preferences, there is a message that says “Please select model in [Device Settings]”. If I click the link I can select the appropriate model from the list. I’m still new to v4 universal drivers but it seems since the driver supports many different models, you have to select the appropriate one. The printer does seem to work without setting a model but I assume there may be some limited functionality.
Any ideas on how to automate setting this this during the installation of the printer?
Thanks for the assistance!
Hmm…. Not sure if you could use the Set-PrinterProperty cmdlet for that… Could you specify or share the driver that you used?
I followed your tip of maybe being able to set it with Set-PrinterProperty. I used Get-PrinterProperty to get a list of property names and the model is indeed a variable. The property name is “Config_Model”
How do you recommend I implement setting the variables with Set-PrinterProperty while using your installation script?
Thanks!
I just tried “Set-PrinterProperty -PrinterName Test -PropertyName Config_Model -Value ‘KONICA_MINOLTAbizhub7925′” (Got the value from the .inf file) Now the message is gone, but all the settings too in preferences and they seem Generic now…. Don’t know what model you have, but you could try to set it to one of the values that matches it from the .inf file…
The value I need in this case is “C650i”.
Can I put it in the script somewhere?
I’ve confirmed that I can use Set-PrinterProperty as you suggested to set Config_Model to the necessary value.
I need to do this on multiple printers. I am wondering what the best way to do this with your script is. Is there a way to add it into the script somehow? Below are the two commands I need to integrate somehow. We have two copiers, one model C550i and one model C650i and I need to set Config_Model as appropriate.
Set-PrinterProperty -PrinterName “KONICA MINOLTA C650i” -PropertyName Config_Model -Value “C650i”
Set-PrinterProperty -PrinterName “KONICA MINOLTA C550i” -PropertyName Config_Model -Value “C550i”
Thanks!
You could add it to the Add_Printers.ps1 and the end, in the “#Add printer and configure it with the required options” section, with a:
#Set Konica Config Model
if ($Printer.Name -match ‘KONICA’) {
Set-PrinterProperty -PrinterName $Printer.Name -PropertyName Config_Model -Value $Printer.DriverName.Split(‘ ‘)[2]
}
This only works if you name the printers like your example so that the last part is used as the model. (Not tested this myself)
Perfect! That worked great.
Thanks for the assistance.
Great to hear, no problem!
The driver is KONICA MINOLTA Universal V4 PCL. Here is a direct link to the download:
https://cscsupportftp.mykonicaminolta.com/DownloadFile/Download.ashx?fileversionid=36295&productid=2275
Hi, Harm Veenstra
Thanks for the post, i have followed the steps and created a folder with all the files you stated with the TOSHIBA printer drivers in the same folder, on testing machine i tried to run the Install.cmd and getting an error as below, looks like the driver is not installed in the driver store when we run the Install.cmd (: The specified driver does not exist in the driver store.)
Windows PowerShell transcript start
Start time: 20230522092638
Username: ***************
RunAs User:**************
Configuration Name:
Machine: DESKTOP-N4QCC9V (Microsoft Windows NT 10.0.19043.0)
Host Application: powershell.exe -executionpolicy bypass -file .\Add_Printers.ps1
Process ID: 2264
PSVersion: 5.1.19041.906
PSEdition: Desktop
PSCompatibleVersions: 1.0, 2.0, 3.0, 4.0, 5.0, 5.1.19041.906
BuildVersion: 10.0.19041.906
CLRVersion: 4.0.30319.42000
WSManStackVersion: 3.0
PSRemotingProtocolVersion: 2.3
SerializationVersion: 1.1.0.1
Transcript started, output file is c:\windows\temp\printers.log
[Install printer driver(s)]
[1/1] Adding inf file C:\Temp\Printers\TOSHIBA\eSf6u.inf
[Add printerdriver(s) to Windows]
[1/1] Adding printerdriver TOSHIBA Universal Printer 2
Add-PrinterDriver : The specified driver does not exist in the driver store.
At C:\Temp\Printers\Add_Printers.ps1:33 char:5
+ Add-PrinterDriver -Name $driver
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (MSFT_PrinterDriver:ROOT/StandardCimv2/MSFT_PrinterDriver)
[Add-PrinterDriver], CimException
+ FullyQualifiedErrorId : HRESULT 0x80070705,Add-PrinterDriver
Add-PrinterDriver : The specified driver does not exist in the driver store.
At C:\Temp\Printers\Add_Printers.ps1:33 char:5
+ Add-PrinterDriver -Name $driver
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (MSFT_PrinterDriver:ROOT/StandardCimv2/MSFT_PrinterDriver) [Add-PrinterDri
ver], CimException
+ FullyQualifiedErrorId : HRESULT 0x80070705,Add-PrinterDriver
[Add printer(s) to Windows]
[1/] Adding printer TOSHIBA
WARNING: Port for Printer TOSHIBA already exists, removing existing port and printer first
Set-PrintConfiguration : The specified printer was not found.
At C:\Temp\Printers\Add_Printers.ps1:78 char:5
+ Set-PrintConfiguration @PrinterConfigOptions
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (MSFT_PrinterConfiguration:ROOT/StandardCi…erConfiguration)
[Set-PrintConfiguration], CimException
+ FullyQualifiedErrorId : HRESULT 0x80070709,Set-PrintConfiguration
Set-PrintConfiguration : The specified printer was not found.
At C:\Temp\Printers\Add_Printers.ps1:78 char:5
+ Set-PrintConfiguration @PrinterConfigOptions
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (MSFT_PrinterConfiguration:ROOT/StandardCi…erConfiguration) [Set-PrintCo
nfiguration], CimException
+ FullyQualifiedErrorId : HRESULT 0x80070709,Set-PrintConfiguration
Windows PowerShell transcript end
End time: 20230522092701
Hi, Harm Veenstra
Thanks for the post, i have followed the steps and created a folder with all the files you stated with the TOSHIBA printer drivers, on testing machine i tried to run the Install.cmd and getting an error as below, looks the driver is not installed in the driver store when we run the Install.cmd
Transcript started, output file is c:\windows\temp\printers.log
[Install printer driver(s)]
[1/1] Adding inf file C:\Temp\Printers\TOSHIBA\eSf6u.inf
[Add printerdriver(s) to Windows]
[1/1] Adding printerdriver TOSHIBA Universal Printer 2
Add-PrinterDriver : The specified driver does not exist in the driver store.
At C:\Temp\Printers\Add_Printers.ps1:33 char:5
+ Add-PrinterDriver -Name $driver
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (MSFT_PrinterDriver:ROOT/StandardCimv2/MSFT_PrinterDriver)
[Add-PrinterDriver], CimException
+ FullyQualifiedErrorId : HRESULT 0x80070705,Add-PrinterDriver
Add-PrinterDriver : The specified driver does not exist in the driver store.
At C:\Temp\Printers\Add_Printers.ps1:33 char:5
+ Add-PrinterDriver -Name $driver
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (MSFT_PrinterDriver:ROOT/StandardCimv2/MSFT_PrinterDriver) [Add-PrinterDri
ver], CimException
+ FullyQualifiedErrorId : HRESULT 0x80070705,Add-PrinterDriver
Is the Toshiba Universal Printer 2 name listed in the inf file? And are all the driver files in that directory, you need them all and not just the inf file.
Hello Harm,
I’m attempting to import the driver from Altec, but I’m encountering an error:
[Add printerdriver(s) to Windows] [1/1] Adding printerdriver Altec ATP-600 Pro Add-PrinterDriver : The specified driver does not exist in the driver store. At C:\Tools\Scripts\Adding Printer Drivers and Printers with Intune\add_printers.ps1:33 char:5 + Add-PrinterDriver -Name $driver + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (MSFT_PrinterDriver:ROOT/StandardCimv2/MSFT_PrinterDriver) [Add-PrinterDri
ver], CimException + FullyQualifiedErrorId : HRESULT 0x80070705,Add-PrinterDriver
And I can’t figure out why. Here is the content of the INF file:
[Version]
Signature=”$Windows NT$”
Provider=%EP%
ClassGUID={4D36E979-E325-11CE-BFC1-08002BE10318}
Class=Printer
CatalogFile=Altec.cat
DriverVer=12/23/2021,10.0.3.23888
DriverPackageDisplayName=%driver-package-description%
DriverPackageType=PlugAndPlay
[Manufacturer]
“%MAN%”=PRINTERMODELS,NTx86,NTamd64
[PRINTERMODELS.NTx86]
“Altec ATP-23″=Altec_ATP_23,USBPRINT\AltecATP-230EBA
“Altec ATP-300 Pro”=Altec_ATP_300_Pro,USBPRINT\AltecATP-300_ProF9E5
“Altec ATP-600″=Altec_ATP_600,USBPRINT\AltecATP-60096CE
“Altec ATP-600 Pro”=Altec_ATP_600_Pro,USBPRINT\AltecATP-600_Pro99B1
“Altec ATP-3000″=Altec_ATP_3000,USBPRINT\AltecATP-30004C17
[PRINTERMODELS.NTamd64]
“Altec ATP-23″=Altec_ATP_23,USBPRINT\AltecATP-230EBA
“Altec ATP-300 Pro”=Altec_ATP_300_Pro,USBPRINT\AltecATP-300_ProF9E5
“Altec ATP-600″=Altec_ATP_600,USBPRINT\AltecATP-60096CE
“Altec ATP-600 Pro”=Altec_ATP_600_Pro,USBPRINT\AltecATP-600_Pro99B1
“Altec ATP-3000″=Altec_ATP_3000,USBPRINT\AltecATP-30004C17
Can you assist me in resolving this issue?
I also have another question: How can I add printers from a print management server? I attempted to add four printers, but I received an error message stating that the port is already in use. The label printers have a specific configuration, and it would be inconvenient for users to have to adjust the settings themselves.
WARNING: Port for Printer P028091 already exists, removing existing port and printer first
Do you have the complete driver directory and the inf file? The script is for directly connecting printers from the intune client without a printserver?
You could add a specific setting for the label printers if you can configure those using set-printerconfiguration
Hi Harm,
Thanks for the great blog and solution.
I followed this blog but I go an error about the detection script.
I think I should edit below part. What name should I put there?
This is my test printers.csv content:
HP Envy 5540_V2,HPWia_EN5540.INF,192.xxxxxxx,HP Envy 5540 Thuis printer,Home
and this is the detection script.
$printers = @(
‘Contoso-General’
‘Contoso-HP’
‘Contoso-MFP’
)
Many thanks!
Your csv should be formatted like this (Like mentioned in the blog post)
Name;DriverName;PortName;Comment;Location
PrinterName;Exact DriverName as found in the .inf file;IP-Address or FQDN of the printer;Comment or description;Location of the printer
Exact drivername is the name of the device and not the driver name 😉 In the detection script, you should use the same name you specified as first in the CSV, HP Envy 5540_V2 in your case
Ah check that’s what I expect and where got wrong. If you add multiple printers, you add them to the detection script below each other then.
Many thanks!
Can you give a sample data just to be sure that correct format is used in the printers.csv.
Sorry you already gave an example, my bad haha
No worries 👍
Thanks Harm for the great script and instructions. I also had issues with the install failing like some of the commenters about the driver not found in the driver store, in my case with a Kyocera v4 driver, I nearly gave up but figured it out. There is no problem with the script. My first try was to copy all the files referenced for my copier in the INF into one folder along with the INF. That failed. Turns out the Kyocera INF file references the files it needs by what level of subfolder they are in compared to the root of the downloaded driver folder. So I needed to download and extract the manufacturer’s ZIP driver folder, then use that entire extracted folder (with its subfolder layout intact) as the source folder instead of just copying the specific files I needed. When your script finds the INF, the INF will be able to point Windows to the proper subfolders within the tree to locate the drivers, some are nested like 4 folders deep. To save space in my intunewin file and remove uneeded INFs, I deleted all the .exe’s, utilities, docs, and the x86 and arm64 folders (which each had their own INFs and drivers I didn’t need) and ended up with just the root folder and 64bit folder tree as well as a metadata folder tree (not sure if I needed that one but left it). This worked first try. Thanks again.
Had the same thing when testing, I just download and extract the whole driver now and yes.. The intunewin file is pretty big sometimes then 😉 Glad it worked out for you now!
Hi,
I have modified the script using the more efficient VMI method for removing printers and ports to update the ip.
I had a lot of problems and errors with the “Remove-Printer” solution.
Below is the script with the correction: https://zpl.cous.re/code/add_printers.ps1
Note that the detection method is not effective on the Intune side, so I switched to a much more reliable registry check.
Ok, didn’t have issues with that in my environments… Can you tell me a bit more if possible? (Perhaps I need to redesign it a bit) And the Detection is fine and I did the PowerShell detection script mainly for logging things, the Registry detection was used before by an other customer but found that to be not that reliable… Pfff… Printers 🙂
I didn’t express myself well.
The detection script works, but for some reason, there were issues with Intune detection.
So, I switched to registry detection, and it works better on Intune.
Regarding the IP change issue, here’s my process:
Target PC: win10-11
Printer IPs change due to network restructuring.
Change the IP in the CSV file and test locally before implementing it on Intune.
There was an error in removing the port.
After checking, the command “Remove-Printer -Name” doesn’t work. The command goes through, but nothing happens.
However, strangely enough, it works perfectly by removing the printer and port using the WMI method.
Additional information:
Hybrid environment
Tested locally on Win10.
PS: thank you for your work, which helps us enormously in this galley that is managing printers 😌
Ok, weird… Could you send me a logfile perhaps? And… Using fqdn for printers solves a lot of those issues 😉
I’m trying to use this on new Windows 11 22H2 laptops. It looks like the drivers aren’t getting copied into the DriveStore folder even though that step shows in the log without indicating an error. However, I’m able to run the install.cmd from an elevated command prompt and the drivers and printers all install successfully. Is there a specific step somewhere that addresses this issue? Is this an issue of a setting in Windows 11 blocking the file copy? Thanks!
That’s odd, are you sure you configured the Intune package to run as System?
“Make sure System is selected as Install behavior (Drivers and printers need to be added with sufficient permissions)”
Hi, thank you for your time writing this script. I am having a network printer shared on a print server like this \servername.com.local\SharpPrinter. Could this work as well for it?
It’s based on local ports and not for shared printers, never tried it but someone did try it in the comments.. And didn’t work..
Pingback: PowerShell is fun :)Overview of 2022 posts
Hi There!
So I’ve gotten this working for our Canon printers, however I’m having a lot of issues with HP. I’m trying to get this to work with an MFP 776.
Unfortunately, the generic pcl 6 driver comes with like 12 .inf files and I think this is causing some issues. Im trying to install the HP Universal Printing PCL 6 driver from the hpcu270u.inf file.
I have attempted removing all other .inf files but it still fails. Here is the log:
Transcript started, output file is C:\Users\prices\Downloads\printers.log
[Install printer driver(s)]
[1/12] Adding inf file C:\Intune Wrapper\Arizona M776\HP\hpbuio200l.inf
[2/12] Adding inf file C:\Intune Wrapper\Arizona M776\HP\hpbuio200le.inf
[3/12] Adding inf file C:\Intune Wrapper\Arizona M776\HP\hpcu270u.inf
[4/12] Adding inf file C:\Intune Wrapper\Arizona M776\HP\hpmews02.inf
[5/12] Adding inf file C:\Intune Wrapper\Arizona M776\HP\hpmldm02.inf
[6/12] Adding inf file C:\Intune Wrapper\Arizona M776\HP\hppewnd.inf
[7/12] Adding inf file C:\Intune Wrapper\Arizona M776\HP\hppfaxnd.inf
[8/12] Adding inf file C:\Intune Wrapper\Arizona M776\HP\hppscnd.inf
[9/12] Adding inf file C:\Intune Wrapper\Arizona M776\HP\hpzid4vp.inf
[10/12] Adding inf file C:\Intune Wrapper\Arizona M776\HP\hpzipa23.inf
[11/12] Adding inf file C:\Intune Wrapper\Arizona M776\HP\hpzipr23.inf
[12/12] Adding inf file C:\Intune Wrapper\Arizona M776\HP\hpzius23.inf
[Add printerdriver(s) to Windows]
[1/1] Adding printerdriver HP Universal Printing PCL 6
Add-PrinterDriver : The specified driver does not exist in the driver store.
At C:\Intune Wrapper\Arizona M776\add_printers.ps1:30 char:5
+ Add-PrinterDriver -Name $driver
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (MSFT_PrinterDriver:ROOT/StandardCimv2/MSFT_PrinterDriver)
[Add-PrinterDriver], CimException
+ FullyQualifiedErrorId : HRESULT 0x80070705,Add-PrinterDriver
Add-PrinterDriver : The specified driver does not exist in the driver store.
At C:\Intune Wrapper\Arizona M776\add_printers.ps1:30 char:5
+ Add-PrinterDriver -Name $driver
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (MSFT_PrinterDriver:ROOT/StandardCimv2/MSFT_PrinterDriver) [Add-PrinterDri
ver], CimException
+ FullyQualifiedErrorId : HRESULT 0x80070705,Add-PrinterDriver
[Add printer(s) to Windows]
[1/] Adding printer HP M776
WARNING: Port for Printer HP M776 already exists, removing existing port and printer first
Set-PrintConfiguration : The specified printer was not found.
At C:\Intune Wrapper\Arizona M776\add_printers.ps1:69 char:5
+ Set-PrintConfiguration @PrinterConfigOptions
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (MSFT_PrinterConfiguration:ROOT/StandardCi…erConfiguration)
[Set-PrintConfiguration], CimException
+ FullyQualifiedErrorId : HRESULT 0x80070709,Set-PrintConfiguration
Set-PrintConfiguration : The specified printer was not found.
At C:\Intune Wrapper\Arizona M776\add_printers.ps1:69 char:5
+ Set-PrintConfiguration @PrinterConfigOptions
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (MSFT_PrinterConfiguration:ROOT/StandardCi…erConfiguration) [Set-PrintCo
nfiguration], CimException
+ FullyQualifiedErrorId : HRESULT 0x80070709,Set-PrintConfiguration
Here is the csv
Name;DriverName;PortName;Comment;Location
HP M776;HP Universal Printing PCL 6;IP Address Removed;HP M776;Arizona SC
Any tips for me?
You just have to place to whole driver folder, doesn’t matter how many .inf files there are in it, in a folder. (That’s the complete folder including subfolders, .exe/.dll./sys etc), There is one .inf file, ususally the largest, which contains the name of the driver that you need to specify. It’s not “HP Universal Printing PCL 6” because it can’t find it in the installed drivers.
Please check your Print Server Properties on your client, Start, type printers & scanners and select Print Server Properties from there. Switch to the Drivers tab and check for the name / model / type of your printer and use that in that file.
Or, from within the same Drivers tab, choose Add, Next, x64, next, have disk, point to the driver folder, select the hpcu270u.inf file and it should display the correct name which you should use in the .csv file.
Let me know how it goes, you can email the link to a zipped version of your driver directory if you want too
Did you manage to get it working?