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.

 1- Create a folder to keep all Printer drivers and scripts in one place.

Intune Printer

2- Copy Printer drivers in Driver folder, make sure you have .inf file

Printer Intune

3- Open the CMD file and make sure that you have an accurate PowerShell script file name

Intune Printer Batch file

@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 SilentlyContinue

if ($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 Driver folder
$DriverInf – This is the filename for the .inf file which contains drivers
$portName & PrinterHost – This is the IP address of the network printer
Add-Printer – This is the name of the Printer which will appear on the PC.

5- Now create an Intune package using 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.

Intune Printer deployment

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)”

Printer Windows App

8- Select App Package file created in step 5

Printer Intune Package
9- Add app information such as Name & Publisher

Intune Network Printer

10- Specify the commands to install and uninstall this app

Intune Printer Script

11- Select both OS system architecture and minimum OS to Windows 10 1607

Intune App Requirement

12- On detection rule, Select “Manually configure detection rules and Rule type Register”

Intune Printer Detection Rule

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 printer using Intune.

 

8 Comments
  1. Mil says

    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..

  2. Harrald Strijker says

    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.

    1. Usman says

      You may need to run the commands one by one and see what’s the output.

  3. Andrew says

    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.

  4. Paul Siwek says

    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”

  5. Trev Farquharson says

    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?

  6. Jeroen Huylebroeck says

    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.

  7. Mark says

    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.

Leave A Reply

Your email address will not be published.