How to Deploy Network Printer via Intune
In this article, We will discuss how we can install a network printer and its drivers using Intune. We will use PowerShell to install printer drivers and create a new printer with its network IP. If you have a printer server installed with a DNS name then we can use a device configuration profile to install the printer which is quite simple and we will discuss this in another post.
Adding Printer Drivers and Printers Using Microsoft Intune
1- Create a folder to keep all Printer drivers and scripts in one place.
2- Copy Printer drivers in Driver folder, make sure you have .inf file
3- Open the CMD file and make sure that you have an accurate PowerShell script file name
@ECHO OFF
SET ThisScriptsDirectory=%~dp0
SET PowerShellScriptPath=%ThisScriptsDirectory%CannonC355i.ps1
PowerShell -NoProfile -ExecutionPolicy Bypass -Command “& ‘%PowerShellScriptPath%'”
PowerShell for Printer installation
4- Open the PowerShell file and make sure that you have made all changes highlighted in the script.
$PSScriptRoot = Split-Path -Parent -Path $MyInvocation.MyCommand.Definition
$DriverName = “Canon Generic Plus PCL6”
$DriverPath = “$PSScriptRoot\Driver”
$DriverInf = “$PSScriptRoot\Driver\Cnp60MA64.INF”
$portName = “10.2.x.x“$checkPortExists = Get-Printerport -Name $portname -ErrorAction SilentlyContinue
if (-not $checkPortExists) {
Add-PrinterPort -name $portName -PrinterHostAddress “10.2.x.x”
}
cscript “C:\Windows\System32\Printing_Admin_Scripts\en-US\Prndrvr.vbs” -a -m “Canon Generic Plus PCL6” -h $DriverPath -i $PSScriptRoot\Driver\Cnp60MA64.INF
$printDriverExists = Get-PrinterDriver -name $DriverName -ErrorAction SilentlyContinueif ($printDriverExists)
{
Add-Printer -Name “Cannon C355i” -PortName $portName -DriverName $DriverName
}
else
{
Write-Warning “Printer Driver not installed”
}
$DriverName – you can find in .inf file in the Driver folder.
$DriverInf – This is the filename for the .inf file which contains the drivers.
$portName & PrinterHost – This is the IP address of the network printer to add the printer by IP.
Add-Printer – This is the name of the Printer which will appear on the PC.
5- Now create an Intune package using the Intune Packaging App. (Change source path and destination folder path)
PS C:\IntuneAppsWinAppsUtil> .\IntuneWinAppUtil.exe
Please specify the source folder: C:\PPackage\Canon C355i\Final
Please specify the setup file: CannonC355i.cmd
Please specify the output folder: C:\PPackage\Canon C355i\Final
Do you want to specify catalog folder (Y/N)?N
This will create an Intune package file in the same folder where all other files exist.
Deploy Printer Using Intune
6- Login to https://endpoint.Microsoft.com and Select Apps
7- Select all Apps and Click to Add. Select App Type to “Windows app (Win32)”
8- Select the App Package file created in Step 5
9- Add app information such as Name & Publisher
10- Specify the commands to install and uninstall this app
11- Select both OS system architecture and minimum OS to Windows 10 1607
12- On the detection rule, Select “Manually configure detection rules and Rule type Registry”
Key path is unique to each printer package, the highlighted name should be the same as mentioned in the script.
Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Print\Printers\Cannon C355i
13– Assign to the group you want to deploy the printer using Intune.
To sum up, this article explains how to set up a network printer and its drivers using Intune. It guides you through organizing printer drivers and scripts, configuring PowerShell files, creating Intune packages, and deploying printers via the Intune portal. By following these steps, you can easily install printers using Microsoft Intune on Windows computers.
Kudos! Work like charm.
I have been looking for such a method to deploy printers for our users in a different site.
We recently setup autopilot and are deploying the devices this way. The only thing I was struggling with, was how to deploy the printers and here I found this perfect solution.
I was trying other methods like setting this up using the device configuration profile, this works but has some shortfalls.
1. Printer installs with the model name and because we have a certain naming policy for our printers, this was not the ideal solution.
2. This can only be assigned to group of user and devices and thats it. Coudn’t be made available through the apps.
With this method, i am able to add the printer name and also make this available via the intune company portal .
Thx again for this great article..
Didnt work 🙁
If you would like to set the installed printer as the Default Printer. Add the following line to your PS1 script.
(New-Object -ComObject WScript.Network).SetDefaultPrinter(‘Printer Name’)
I placed this line of code after:
Add-Printer -Name “Printer Name” -PortName $portName -DriverName $DriverName
So end result would be:
{
Add-Printer -Name “Printer Name” -PortName $portName -DriverName $DriverName
(New-Object -ComObject WScript.Network).SetDefaultPrinter(‘Printer Name’)
}
I tried using your suggestion. However it doesn’t work for me. Any ideas why? I also tried it with “” instead ” but no difference.
Add-Printer -Name “Printer Name” -PortName $portName -DriverName $DriverName
(New-Object -ComObject WScript.Network).SetDefaultPrinter(‘Printer Name’)
Set-PrintConfiguration -PrinterName “Printer Name” -PaperSize A4 -duplexingmode TwoSidedLongEdge
Hi Tim,
I have tried adding your line to the below. However it doesn’t work for me and I’m not sure why. Any suggestions? I have also tried using “” instead ” but this made no difference.
{
Add-Printer -Name “Printer Name” -PortName $portName -DriverName $DriverName
(New-Object -ComObject WScript.Network).SetDefaultPrinter(‘Printer Name’)
Set-PrintConfiguration -PrinterName “Printer Name” -PaperSize A4 -duplexingmode TwoSidedLongEdge
}
Thanks, Martin
Hello,
I can’t get it to work. The ps1 file I created works fine, but is does not run automatic.
The cmd file seems to be wrong.
When I run the cmd lin by line, i get an error.
& : The term ‘%~dp0HPZwolle.ps1′ is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:3
+ & ‘%~dp0HPZwolle.ps1’
+ ~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (%~dp0HPZwolle.ps1:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Hello.
I have worked with your solution, but I cannot get it to work.
For some reason the last line in the cmd file does not work.
The error I get is: The term ‘%~dp0Plotter.ps1’ is not recognized as the name of a cmdlet, function, script file, or operable program.
When I run the ps1 script seperately, the printer is installed correctly.
You may need to run the commands one by one and see what’s the output.
Thank you!! I was struggling with other methods I found to automate local IP printer installs (serverless) with Intune, and your article nailed it.
The only thing I had to change was the last line in the .cmd file:
PowerShell -NoProfile -ExecutionPolicy Bypass -Command .\CannonC355i.ps1
After that it worked perfectly, and I’ve started deploying this to my customers.
Hi Andrew,
I have a small trouble working with this script it worked for few printers and for specific one it fails only from intune.
Manually running it works like a charm.
I am getting 0x80070001 error code, I am not sure if i am leaving anything missing.
I’ve tried this and deployed to some Intune devices, however it’s failing and showing as 0x87D1041C i think meaning it couldn’t detect if it was installed.
however the printer is not showing, but when running manually on a domain joined device, the script works perfectly.
Our Intune devices are on the same IP range as our wired Desktops.
We use a Hybrid network so Local AD Synced with AAD, we also use Uniflow as our print management solution.
If i Run the script as myself, presumably i have higher permission that most users, the script runs and the printer is added, and i can print (even using secure print”
We have printers on remote sites that are not connected to our network, so the printer port is not detectable when deploying/setting up the laptop.
How do we make the script work for this situation?
You will need to use lpr printing; set up the LPD print service on your print server, then you can use the Add-Printer command with -LprHostAddress and -LprQueueName to install the printer without needing to access it
I’d like to give a small remark: when copying the code there’s a mistake, it delivers “ instead of ” and ‘ instead of ‘, which results in errors.
Hi thanks for these instructions – the first time I tried to work them through it failed. However, on my second attempt a month later, I made two changes that I know of which seemed to do the trick.
1. I changed all the smart quotes (like this “ ” ) to dumb ones (like this ” ” ) – that one has caught me out programming HTML before now so I should have spotted it.
2. The final change in the .ps1 document (Add-Printer -Name) should be exactly the same as the end of the Registry Key Path used in step 12 (including any spaces).
Hope that helps anyone else who’s working through these steps.
Removing the printer with the same CMD doesnt seem to work.
Is it possible to implement 2 powershell scripts into 1 .intunwin file or how should this work?
I need to set up the printer this way, but add a secure print setting. tell me how to do it please
How can you now add network printers? What do you need to change within the script?
Hi,
Thanks for this, it works perfectly 🙂
Do you know the settings/scripts to uninstall it from Intune?
Thanks
How can I use the script to only install device drivers (ie: HP Universal Printer Drivers) without prompting for any other ports, ip, etc for specific printers. I’d also like to add a line for logging into a txt file.
Any advice would be appreicated.
The script works great when I run it manually but fails in Intune with “The application was not detected after installation completed successfully (0x87D1041C)”. Any suggestions on how to troubleshoot?
Also had this happen to me. In my case, at first I didn’t use the .bat script to call the powershell script, rather just win32 wrapped the driver and powershell script. The issue ended up being Intune couldn’t detect the printer because the actual adding of the printer happened after the powershell script ran. Intune detection just missed it. If you follow this article exactly and use the .bat script to call the powershell script, the powerhshell completes and then the .bat completes which is enough time for the printer to show up and Intune to detect it.
Hi, you mention “If you have a printer server installed with a DNS name then we can use a device configuration profile to install the printer which is quite simple”. I am not really sure how simple is this, I cannot find any information how to do this with configuration profile. I will be glad if you have the guide somewhere. Thank you.