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!