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.
Thank you for providing this excellent tutorial.
May I seek your assistance? I am encountering the issue where the application is not detected after a successful installation (Error 0x87D1041C), although the printer is installed. I have verified that the printer name is correctly populated, as per your previous comment in the detection script. Despite republishing the Intune file and associating it with the w32app, I am still encountering the error message. Could you please help?
Does your detection.ps1 match all the printer names from the CSV file? And after uploading the new .intunewin file, did you also upload a new detection.ps1 to the app in Intune?
Harm, thank you for your response. Indeed I didn’t upload the new
detection.ps1 to the app in Intune.
Hi Harm, we are moving from a print server to Azure Universal print. Now users are still using the ‘ old’ printers on their systems. I want to remove the ‘ old’ printers to get them use the Universal print printers. Do you also have a script which retrieves all installed printers and printer drivers on Intune managed devices? I expect we will see different drivers 🙁
Don’t have anything for that (yet), but what you could do is run a script that detects printers that were using the print server and removes all that were found. Something like this should work:
Get-Printer | Where-Object ComputerName -eq ‘Printservername’ | Remove-Printer -Confirm:$false
Drivers shouldn’t matter anymore if you’re using Universal Print right?
Thank you, indeed drivers doesn’t matter anymore.
Let me know if it works out for you!
Yes, it worked out for me by creating a detection and removal script.
Nice, great to hear!
Unfortunately I get errors on some devices when the detection and remediation scripts are running on user devices.
Remove-Printer : Access was denied to the specified resource. At C:\WINDOWS\IMECache\HealthScripts\1597f1b0-1e1c-424e-a5ea-e675e3e89366_3\remediate.ps1:2 char:60 + … Object PortName -eq “192.168.35.242” | Remove-Printer -Confirm:$false + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : PermissionDenied: (MSFT_Printer (N… = 0, Type = 0):ROOT/StandardCimv2/MSFT_Printer) [R emove-Printer], CimException + FullyQualifiedErrorId : HRESULT 0x80070005,Remove-Printer
I run the scripts using the logged-on credentials.
Is there a way to force the removal of the printers even the user doesn’t have the rights?
It should be run as System, not as user in order to install drivers, but also to remove them (I mentioned that in the adding the package to intune section)
I have been trying to get this running but cannot even get off the mark. The Intune package installs but the scripts do not start. I see the installer script is allowing the Add_Printers.ps1 to run but it seems to not launch (Win 11 23H2) because it doesn’t start it doesn’t even create the log.
I originally made the script for three Kyocera printers but when i had issues I started again and just set it up for one.
Not sure why I cannot get it running.
If it doesn’t even create the logfile… Then the script doesn’t start, Start-Transcript is the first thing is does (Logging to c:\windows\temp). The Intune package shouldn’t install because the detection would fail afterwards, there are no errors in Intune stating that?
Hi Harm, This is the strange part my Intune policy shows “Installed” 1 and is Blue so everything looks great.
CND0183MD9
admin@DomainName.com
Windows 10.0.22631.3007
1.2
Installed
31/01/2024, 10:14:38
I go onto the machine and check devices and printer and nothing is there so I check company portal and that shows the package as installed. I then head over to C:\Windows\Temp looking for “printers.log” but nothing there. I then attempt a restart but no difference.
I have install.cmd as…
powershell.exe -executionpolicy bypass -file .\Add_Printers.ps1
Then Add_Printers.ps1 as…
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.ART
DriverName = $Printer.Kyocera TASKalfa 4053ci KX
Location = $Printer.HQ
Name = $Printer.ART
PortName = $Printer.10.98.76.152
}
$PrinterConfigOptions = @{Color = $True
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
That script calls Printers.csv which i have as…
Name;DriverName;PortName;Comment;Location
ART;Kyocera TASKalfa 4053ci KX;10.98.76.152;ART;HQ
Then detection should run which I have as…
$printers = @(
‘ART’
)
#Check every printer if it’s installed
$numberofprintersfound = 1
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
}
The Intune setup is just as per the guide. Have I missed loads of sections out on the script that I needed to edit?
You changed the PrinterAddOptions in Add_Printers.ps1 to this:
#Set options for adding printers and their ports
$PrinterAddOptions = @{
ComputerName = $env:COMPUTERNAME
Comment = $Printer.ART
DriverName = $Printer.Kyocera TASKalfa 4053ci KX
Location = $Printer.HQ
Name = $Printer.ART
PortName = $Printer.10.98.76.152
}
You should leave them as:
$PrinterAddOptions = @{
ComputerName = $env:COMPUTERNAME
Comment = $Printer.Comment
DriverName = $Printer.DriverName
Location = $Printer.Location
Name = $Printer.Name
PortName = $Printer.Name
}
It uses the fields from the .csv
Hi Harm, I finally got some time back on this and took the advice from your reply. Having overengineered your script, I started again from scratch. I tested the script by manually running it, and it worked perfect. I have just headed over to Intune and created a new .intunewin file. The first rollout has been a success, so I am pushing it to another test machine now. I really appreciate your reply to my issues Harm, so thank you.
Thanks for reporting back, no problem and good to hear that everything is working like it should!
And thanks for the coffee, I appreciate it!
Hello Harm,
Thanks again for putting this together. Can you point me in the direction to find out how I can set the following print options for a printer:
paper size ArchD
Rotate 90 degress
Landscape
roll size 36″
I assume I would need a separate/dedicated Intune package for this printer otherwise all the printers will have these print options?
Thanks in advance,
Dan
Creating a seperate package would be the easiest option for this, I used the Set-PrintConfiguration cmdlet in the script for setting the options. (https://learn.microsoft.com/en-us/powershell/module/printmanagement/set-printconfiguration?view=windowsserver2022-ps) Paperoptions (https://learn.microsoft.com/en-us/powershell/module/printmanagement/set-printconfiguration?view=windowsserver2022-ps#-papersize) are here, No ArchD there 🙁
Is there a way to push out specific default printer options say Single Page /BW ( Black White)
Yes, you can review the options here https://learn.microsoft.com/en-us/powershell/module/printmanagement/set-printconfiguration?view=windowsserver2022-ps . Use those parameters and values inside the script in the $PrinterConfigOptions section
Would anyone happen to know how I can determine the print driver name for brother printers?
It’s in the biggest inf file mostly, but you can also see the name when adding the printer manually to windows in the print server options
Thanks Harm.
I receive an error;
[Add printer(s) to Windows]
[1/] Adding printer
PS>TerminatingError(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.”
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:\Windows\IMECache\1c67cf74-6ec7-4a3e-ab86-6ed856dd8fa7_1\add_printers.ps1:67 char:21
+ Add-PrinterPort @PrinterPortOptions
&
TerminatingError(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.”
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:\Windows\IMECache\1c67cf74-6ec7-4a3e-ab86-6ed856dd8fa7_1\add_printers.ps1:69 char:28
+ Set-PrintConfiguration @PrinterConfigOptions
+ ~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (:) [Set-PrintConfiguration], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,Set-PrintConfiguration
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:\Windows\IMECache\1c67cf74-6ec7-4a3e-ab86-6ed856dd8fa7_1\add_printers.ps1:69 char:28
+ Set-PrintConfiguration @PrinterConfigOptions
The CSV is as follows;
Name; Drivername:Portname:Comment:Location
Ricoh;Ricoh IM C2000 PCL 6; 192.168.2.30; Company;Office
What am I doing wrong?
I think the csv is not correctly formatted, could you post the first two lines of it?
Thanks for this, Im running into an error, the Add_printers.ps1 is looking for the the printers.csv in System32 for some reason? Error message below.
Import-Csv : Could not find file ‘C:\WINDOWS\system32\printers.csv’.
At C:\Users\Gary\My Drive\Barnes wiki\Intune\Printers\Printers\Add_Printers.ps1:3 char:13
+ $Printers = Import-Csv .\printers.csv -Delimiter ‘;’
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OpenError: (:) [Import-Csv], FileNotFoundException
+ FullyQualifiedErrorId : FileOpenFailure,Microsoft.PowerShell.Commands.ImportCsvCommand
No changes have been made to your script on this
Start-Transcript -Path c:\windows\temp\printers.log
#Read printers.csv as input
$Printers = Import-Csv .\printers.csv -Delimiter ‘;’
The printers.csv should be in your Intune package, how does the folder look that you use to create to Intunewin file from? If you just run the script in ISE or VSCode, please change directory to C:\Users\Gary\My Drive\Barnes wiki\Intune\Printers\Printers first because it expects the .csv file in your current directory
Hello,
I have a problem when deploying through Intune. I always encounter an issue. Intune indicates that the installation was not necessary. Therefore, an error is displayed on the PCs, and I cannot proceed with the PC.
How can I resolve this issue?
The application was not detected after installation completed successfully (0x87D1041C)
Could you share your detection script?
Any idea what am i doing wrong ? I made no changes to the script, running it in a test environment and this is what i get.
C:\temp\PrinterIntune\AddPrinterIntune>powershell.exe -executionpolicy bypass -file .\add_printers.ps1
Transcript started, output file is c:\windows\temp\printers.log
[Install printer driver(s)]
[1/3] Adding inf file C:\temp\PrinterIntune\AddPrinterIntune\Canon\CNP60MA64.INF
[2/3] Adding inf file C:\temp\PrinterIntune\AddPrinterIntune\HP\hpcu250u.inf
[3/3] Adding inf file C:\temp\PrinterIntune\AddPrinterIntune\TOSHIBA\esf6u.inf
[Add printerdriver(s) to Windows]
[1/3] Adding printerdriver TOSHIBA Universal Printer 2
Add-PrinterDriver : The specified driver does not exist in the driver store.
At C:\temp\PrinterIntune\AddPrinterIntune\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
I think “TOSHIBA Universal Printer 2” is not the name like it it in the esf6u.inf? Could you check the installed driver in your Print Server properties to get the complete driver list and the correct Display Name.
Harm, this is the content of the file. This is happening to all the 3 printers that come with the script.
No changes were made in any files.
; Copyright (c) 2020 Toshiba Tec Corporation, All Rights Reserved.
; Delta: 4835
[Version]
Signature=”$Windows NT$”
Provider=%TOSH%
ClassGUID={4D36E979-E325-11CE-BFC1-08002BE10318}
Class=Printer
CatalogFile=eSf6u.cat
DriverVer=06/02/2020,7.212.4835.17
DriverIsolation=2
[Manufacturer]
%TOSH%=TOSHIBA,NTamd64,NTamd64.6.0
[TOSHIBA]
“TOSHIBA Universal Printer 2” = install_pre_vista,TOSHIBATOSHIBA_Unive5D6E,1284_CID_TS_PCL6_Color
“TOSHIBA Universal Printer 2” = install_pre_vista,USBPRINT\TOSHIBAe-STUDIO6550CD363
“TOSHIBA Universal Printer 2” = install_pre_vista,USBPRINT\TOSHIBAe-STUDIO6540C1332
“TOSHIBA Universal Printer 2” = install_pre_vista,USBPRINT\TOSHIBAe-STUDIO5540C1376
“TOSHIBA Universal Printer 2” = install_pre_vista,USBPRINT\TOSHIBAe-STUDIO5055C4F24
“TOSHIBA Universal Printer 2” = install_pre_vista,USBPRINT\TOSHIBAe-STUDIO4555C4119
“TOSHIBA Universal Printer 2” = install_pre_vista,USBPRINT\TOSHIBAe-STUDIO4540CD34B
“TOSHIBA Universal Printer 2” = install_pre_vista,USBPRINT\TOSHIBAe-STUDIO3555C81AC
“TOSHIBA Universal Printer 2” = install_pre_vista,USBPRINT\TOSHIBAe-STUDIO3540C13FE
“TOSHIBA Universal Printer 2” = install_pre_vista,USBPRINT\TOSHIBAe-STUDIO3055C4FAC
Seems to be ok… Could you post the output from Get-PrinterDriver?
Problem solved. I think the script will not run if the system is not up to date.
Get-PrinterDriver was not working properly. After windows updates, Get-PrinterDriver started working and script installing the printers.
Thank you.
Ah 👍 good to hear!
Having the exact issue with Toshiba drivers. Manually going through the script it looks like its failing because the Toshiba drivers are not signed? “Adding the driver package failed : The hash for the file is not present in the specified catalog file. The file is likely corrupt or the victim of tampering.”
Is there a .cat file present in the downloaded driver? Could you share the downloadlink?
Thanks Harm for the fast reply! Yes there is a cat file and seems to be referenced correctly. I also have seen an error saying “Windows Cant verify the publisher of this driver software”.
https://downloads.toshibatec.eu/publicsite-service/resource/download/pseu/en/99db3107-ae29-46f5-9c29-b5ad6b67fa98/9ffe43ddcb238cfed5c1ec17ed1f2c3e/TOSHIBA_e-STUDIO_Universal_Printer_Driver_2_v7.222.5412.81.zip
Example download link ^^^
Odd. the download just downloaded a version with different time stamps. Might be a false error. Ill give it ago with this. Thanks
I tried the one from your link and it seems to be added to Windows like normal (I’m testing this from within Windows Sandbox, this is with more relaxed security settings then you might have configured)
Thanks, yes think there was something wrong with previous driver. However, I still cannot get the Toshiba drivers to work. I have confirmed the name matches the csv and the actual name in the inf file. I have even tested on my test machine that works, but not for the 60 machines I am deploying too.
[4/5] Adding inf file C:\Windows\IMECache\02fccd07-e819-454e-b3bb-73cbbfe56959_4\TOSHIBA\eSf6p.inf
[5/5] Adding inf file C:\Windows\IMECache\02fccd07-e819-454e-b3bb-73cbbfe56959_4\TOSHIBA\eSf6u.inf
[4/5] Adding printerdriver TOSHIBA Universal Printer 2
Add-PrinterDriver : The specified driver does not exist in the driver store.
Get-printerdriver doesnt show the driver there but I suspect PnPUtil is not working correctly on some machines even though it says it is importing the drivers. I have attempted to change the PnPUtil commands to the new /add-driver /install commands so will report back if there is any difference.
Could you zip the files and send me a link?
Thanks, Have sent you via email
Thanks, I extracted the contents and ran it in a Windows Sandbox session without any issue… Just to confirm… You do have System as Installation Behavior configured? (Windows Sandbox runs things in Admin node and installed all 19 printers without any issue)
Weirdly, all printers started to install yesterday. Seems to match Flavio’s experience with Windows updates. Thanks for taking a look and thanks for the script!
No problem, strange and bit curious about what was fixed in those updates… Glad it works now!
How to install only the print drivers?
You could use a part of the script that only does the pnputil and add-printerdriver part. The detection, however, needs to be changed… I will put it on my ToDo list 🙂
Uhm.. I alread wrote a blog post about that in the past 🙂 https://powershellisfun.com/2022/06/21/adding-printer-drivers-with-endpoint-manager-and-powershell/
For me the printer installed successfully but I don’t see the printer in laptop in apps and features or any location where can I find it
If you search for printers in the Start Menu, and open it… They are not there?
Hi,
I’m stuck with Brother label printer drivers. Drivers wont installing.
Model: Brother TJ-4005DN
https://www.brother.co.uk/support/tj-4005dn/downloads
Log starting:
Transcript started, output file is c:\windows\temp\printers.log
[Install printer driver(s)]
[1/1] Adding inf file C:\Windows\IMECache\59c8c49f-0cf4-4fa4-bfb4-0b4b6758bae6_1\Brother\Brother.inf
[Add printerdriver(s) to Windows]
[1/1] Adding printerdriver Brother TJ-4005DN
Add-PrinterDriver : The specified driver does not exist in the driver store.
At C:\Windows\IMECache\59c8c49f-0cf4-4fa4-bfb4-0b4b6758bae6_1\add_printers.ps1:33 char:5
+ Add-PrinterDriver -Name $driver
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (MSFT_PrinterDriver:ROOT/StandardCimv2/MSFT_PrinterDriver) [Add-PrinterDrive
r], CimException
+ FullyQualifiedErrorId : HRESULT 0x80070705,Add-PrinterDriver
Add-PrinterDriver : The specified driver does not exist in the driver store.
At C:\Windows\IMECache\59c8c49f-0cf4-4fa4-bfb4-0b4b6758bae6_1\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 BrotherLX ETIKETIT
WARNING: Port for Printer BrotherLX ETIKETIT already exists, removing existing port and printer first
Set-PrintConfiguration : The specified printer was not found.
At C:\Windows\IMECache\59c8c49f-0cf4-4fa4-bfb4-0b4b6758bae6_1\add_printers.ps1:77 char:5
+ Set-PrintConfiguration @PrinterConfigOptions
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (MSFT_PrinterConfiguration:ROOT/StandardCi…erConfiguration) [Set-PrintConf
iguration], CimException
+ FullyQualifiedErrorId : HRESULT 0x80070709,Set-PrintConfiguration
Set-PrintConfiguration : The specified printer was not found.
At C:\Windows\IMECache\59c8c49f-0cf4-4fa4-bfb4-0b4b6758bae6_1\add_printers.ps1:77 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: 20240520123433
Thanks for any help!
Could you please the link to the driver being used? Or share your files with me using OneDrive or Google Drive?
Here is the download link:
https://www.brother.co.uk/support/tj-4005dn/downloads
OS selection: windows 11
Printer driver version: 02/06/2022 (2021.3_M-0)
Thanks, I will look at it later today!
Pnputil.exe returns “Adding the driver package failed : The publisher of an Authenticode(tm) signed catalog was not established as trusted.” and doesn’t add the printer driver because of that…
Perhaps you can try this? https://support.seagullscientific.com/hc/en-us/articles/217079018-Installing-Authenticode-signature-prior-to-Seagull-Driver-installation
Thanks! I added certificate to trusted publishers using Intune and now printer installation works fine!
Nice, didn’t run into the issue myself before but now we now how to fix it!
Your solution worked perfectly. Now I would like to remove the printers from the computers via Intune. How should I go about this?
Thanks! And you can assign a group to uninstall the Win32package. (From the last steps in the Uploading the .intunewin package chapter, choose uninstall instead of Required)
It worked. Thank you!
Nice! Have a great weekend!
Hey harm, how do we know what ip adress to use? I.e im trying to use this to create a universal print driver for several printers but the ip adresses are not defined? where would i find that info? or do i just use a random ip?
Your IT/Network admins should have that information for you? I do recommend to use DNS names, like printer01.domain.local, so if the IP-address changes… The printer will still work. But if you use it just to distribute the driver… You can search my blogs for the one that just installs the driver. –> https://powershellisfun.com/2022/06/21/adding-printer-drivers-with-endpoint-manager-and-powershell/
Hi,
I’m installing the HP Universal Printing PCL 6 driver for the printer HP PageWide Pro 477dw MFP. It is a color printer but even if I enable the Color tab and untick the grayscale it is still not printing in color.
Any suggestions?
You’re not using the specific driver for the printer? Why the Universal driver? But even the Universal Driver should print in color if you select it… Could you try switching the driver to the one from https://support.hp.com/us-en/drivers/hp-pagewide-pro-477dw-multifunction-printer-series/7439472 ?
I downloaded and extracted the files but I am not sure what .inf and other files is needed?
Just put them all in a subfolder, the script will install all the drivers from all subfolders. Just follow the blog post and make sure the Printer Driver name is correct
After extracting the folder it is 392MB. Do I really need all the files? I am still a bit unsure what files are needed beside .inf files. Would love to have only needed files.
BTW, your script is very nice!
Br. MK
Perhaps not all, but it’s hard to trim that down. Sometimes it’s multilingual and multiple windows versions… I alway use the most compact driver, without any gui tools or monitor applications which gives you toner information etc.
Hi,
I have now this printer: https://support.hp.com/hk-en/drivers/hp-color-laserjet-enterprise-mfp-5800dn-printer-series/2101294747
But I have problems finding the correct DriverName in the inf files. I have downloaded these PCL-6 drivers https://ftp.hp.com/pub/softlib/software13/printers/CLJ5800/V4_DriveronlyWebpack-57.2.5371-CLJ5800_V4_DriveronlyWebpack.exe
Do you have a clue what DriverName I should use for this printer (I need the PCL-6 drivers)?
Your script is working very well with older printers!
Br. MK
Always difficult to get the good name 🙂 What I usually do, is install the driver using Settings/Printer and scanners/Print Server Options/Dirvers/Add… When done, it will display the name in that screen which you can use.
Ok, I did that. It says “HP Smart Universal Printing”. Is this correct? I thought I would need a driver that says something like “HP Color LaserJet MFP 5800 PCL-6”. I have other printers and the DriverName that I found in the inf for that printer is “HP Color LaserJet M552 PCL-6”.
I would like to have the correct PCL-6 driver for HP Color LaserJet Enterprise MFP 5800dn Printer series.
Thanks for your help in this matter!
Br. MK
Universal is usually limited, there were more sub folders when I extracted your driver from that link?
All folders list the Universal driver…
Very strange that I canno’t find specific PCL drivers to “HP Color LaserJet Enterprise MFP 5800dn Printer series”.
Br. MK
Same, like they only do Universal now?
I asked HP Support and got below answer:
“HP on newer printers several years now has only universal PCL or PS drivers. They don’t provide anymore specific PCL drivers for specific models”
If I’m using HP’s Universal PCL driver to deploy the printer do you see any conserns with your method? Do I need to do any adjustments because it’s a color printer?
Br MK
Shouldn’t be a problem, you could change the script so that it doesn’t default to black/white (Remove ” Color = $False” )