Adding printer drivers and printers using Microsoft Intune and PowerShell

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.

180 thoughts on “Adding printer drivers and printers using Microsoft Intune and PowerShell

  1. Pingback: Blog post – Adding printer drivers and printers using Intune – 247 TECH

  2. Pingback: Intune Newsletter - 9th December 2022 - Andrew Taylor

    • 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

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

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

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

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

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

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

    • FullyQualifiedErrorId: HRESULT 0x80070705,Add-PrinterDriver
      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

    • 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 ?

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

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

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

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

    • 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

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

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

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

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

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

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

      • 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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

  33. Pingback: PowerShell is fun :)Overview of 2022 posts

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

  35. Harm,

    Thanks for these easy to use instructions. Its made my life much easier. Is there any way to use a different port than 9100 for specific printer? We still have a few old jet directs and require the different port like 9101.

    Thanks again,
    Anthony

    • Thank you 😊 you could create a seperate package for those with a modified add_printers.ps1 script containing this changed part

      $PrinterPortOptions = @{
      ComputerName = $env:COMPUTERNAME
      Name = $Printer.Name
      PrinterHostAddress = $Printer.PortName
      PortNumber = ‘9101’
      }

  36. Hi Harm,

    Thanks for sharing the script, I tested the script, its giving error as “The specified driver does not exist in the driver store.” what does that mean? could you please help on this also for adding scanner. below is the printer log

    (Microsoft Windows NT 10.0.22621.0)
    Host Application: powershell.exe -executionpolicy bypass -file .\add_printers.ps1
    Process ID: 13972
    PSVersion: 5.1.22621.2506
    PSEdition: Desktop
    PSCompatibleVersions: 1.0, 2.0, 3.0, 4.0, 5.0, 5.1.22621.2506
    BuildVersion: 10.0.22621.2506
    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/4] Adding inf file C:\Temp\Printers\HP\autorun.inf
    [2/4] Adding inf file C:\Temp\Printers\HP\hpbuio70l.inf
    [3/4] Adding inf file C:\Temp\Printers\HP\hpcm125126.inf
    [4/4] Adding inf file C:\Temp\Printers\HP\hppasc_lj125126.inf

    [Add printerdriver(s) to Windows]
    [1/1] Adding printerdriver HP LaserJet Pro MFP M125-M126 PCLmS
    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-PrinterDriver], CimException
    + FullyQualifiedErrorId : HRESULT 0x80070705,Add-PrinterDriver

    [Add printer(s) to Windows]
    [1/] Adding printer HP Printer
    WARNING: Port for Printer HP Printer already exists, removing existing port and printer first
    Set-PrintConfiguration : The specified printer was not found.
    At C:\Temp\Printers\add_printers.ps1:77 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:77 char:5
    + Set-PrintConfiguration @PrinterConfigOptions
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : NotSpecified: (MSFT_PrinterConfiguration:ROOT/StandardCi…erConfiguration) [Set-PrintConfiguration], CimException
    + FullyQualifiedErrorId : HRESULT 0x80070709,Set-PrintConfiguration

    Windows PowerShell transcript end
    End time: 20231130201158

    • I downloaded the driver and testing it for you, usually it’s something in the driver name but it seems correct… Let me check 🙂 Ok, it does work for me:

      Transcript started, output file is c:\windows\temp\printers.log
      [Install printer driver(s)]

      [1/4] Adding inf file C:\Users\WDAGUtilityAccount\Desktop\New folder\Driver\autorun.inf
      [2/4] Adding inf file C:\Users\WDAGUtilityAccount\Desktop\New folder\Driver\hpbuio70l.inf
      [3/4] Adding inf file C:\Users\WDAGUtilityAccount\Desktop\New folder\Driver\hpcm125126.inf
      [4/4] Adding inf file C:\Users\WDAGUtilityAccount\Desktop\New folder\Driver\hppasc_lj125126.inf

      [Add printerdriver(s) to Windows]
      [1/1] Adding printerdriver HP LaserJet Pro MFP M125-M126 PCLmS

      [Add printer(s) to Windows]
      [1/] Adding printer Test
      Transcript stopped, output file is C:\windows\temp\printers.log

      This is the contents of my .CSV file:

      Name;DriverName;PortName;Comment;Location
      Test;HP LaserJet Pro MFP M125-M126 PCLmS;192.1.2.3;Test;Test

      How does your one look? Perhaps the .csv isn’t correctly formatted?

      • Thanks for your time, I copied your content and saved as .csv still same issue.

        Transcript started, output file is c:\windows\temp\printers.log
        [Install printer driver(s)]
        [1/4] Adding inf file C:\Temp\Printers\HP\autorun.inf
        [2/4] Adding inf file C:\Temp\Printers\HP\hpbuio70l.inf
        [3/4] Adding inf file C:\Temp\Printers\HP\hpcm125126.inf
        [4/4] Adding inf file C:\Temp\Printers\HP\hppasc_lj125126.inf

        [Add printerdriver(s) to Windows]
        [1/1] Adding printerdriver HP LaserJet Pro MFP M125-M126 PCLmS
        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-PrinterDriver], CimException
        + FullyQualifiedErrorId : HRESULT 0x80070705,Add-PrinterDriver

        [Add printer(s) to Windows]
        [1/] Adding printer Test
        Set-PrintConfiguration : The specified printer was not found.
        At C:\Temp\Printers\Add_Printers.ps1:77 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:77 char:5
        + Set-PrintConfiguration @PrinterConfigOptions
        + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo : NotSpecified: (MSFT_PrinterConfiguration:ROOT/StandardCi…erConfiguration) [Set-PrintConfiguration], CimException
        + FullyQualifiedErrorId : HRESULT 0x80070709,Set-PrintConfiguration

        Windows PowerShell transcript end
        End time: 20231130212447

    • If you run Get-PrinterDriver on that system, what do you get? You should see at least this…

      Get-PrinterDriver

      Name PrinterEnvironment MajorVersion Manufacturer
      —- —————— ———— ————
      HP LaserJet Pro MFP M125-M126 PCLmS Windows x64 3 Hewlett Packard

      • Getting below result

        Name PrinterEnvironment MajorVersion Manufacturer
        —- —————— ———— ————
        HP Smart Universal Printing Windows x64 4 HP

  37. Ok, the printer driver is not installed so that makes sense… You have all the driver files in one subfolder, not just the .inf files I hope? My folder size for this driver is 196Mb with 1117 files and 220 folders.

  38. Oops my bad, from today afternoon I was trying with standard privileges.
    able to run successfully with elevated privileges, sorry for my mistake and thank you so much for your help.

    Have 2 more question.
    1) can we add USB connected printer through this method?
    2) is it possible to add scanner?

      • If you can install the driver for it and point to an ip-address to add it to Windows, everything is possible with this script I guess. But USB devices… You could shorten the script to only install the drivers. Remove everything between line 35 and 80 so that it only installs the drivers. You would have to change the detection script to use get-printerdriver and see if the drivers are installed. If the user connects a device using USB, the drivers will be found and it should work (Didn’t test this)

  39. Hi Harm,
    Having the hardest time getting a Sharp MX-3071S PCL6 print driver installed. Getting the error driver cannot be found. I confirmed I have the right driver name in the csv file and all the files are in the directory.

    Weird thing is that the printer driver does install on all Windows 10 machines but NOT for any Windows 11 machines.

    Any idea?

    Kind regards,
    Dan

    • I downloaded the driver and it does seem to install in Windows 11 when using Pnputil.exe:

      [1/1] Adding inf file C:\Users\WDAGUtilityAccount\Desktop\64bit\Driver\su2emnld.inf

      PS C:\Users\WDAGUtilityAccount\Desktop\64bit> Add-PrinterDriver -Name ‘SHARP MX-3071S PCL6’

      PS C:\Users\WDAGUtilityAccount\Desktop\64bit> Get-PrinterDriver

      Name PrinterEnvironment MajorVersion Manufacturer
      —- —————— ———— ————
      SHARP MX-3071S PCL6 Windows x64 3 SHARP
      Remote Desktop Easy Print Windows x64 3 Microsoft
      Microsoft enhanced Point and Pri… Windows x64 3 Microsoft
      Microsoft enhanced Point and Pri… Windows NT x86 3 Microsoft

      Could you give me the output of Get-PrinterDriver on that Windows 11 machine which doesn’t install?

  40. Hmm, ok. yeah, it’s not installing with the driver download that I got from Sharp. here’s the output of get-printerdriver:

    PS C:\WINDOWS\system32> get-printerdriver

    Name PrinterEnvironment MajorVersion Manufacturer
    —- —————— ———— ————
    HP ColorLaserJet MFP M282-M285 P… Windows x64 4 hp
    Send to Microsoft OneNote 16 Driver Windows x64 4 Microsoft
    Microsoft XPS Document Writer v4 Windows x64 4 Microsoft
    Microsoft Software Printer Driver Windows x64 4 Microsoft
    Microsoft PWG Raster Class Driver Windows x64 4 Microsoft
    Microsoft Print To PDF Windows x64 4 Microsoft
    Microsoft OpenXPS Class Driver 2 Windows x64 4 Microsoft
    Microsoft MS-XPS Class Driver 2 Windows x64 4 Microsoft
    Microsoft IPP Class Driver Windows x64 4 Microsoft
    Lexmark MS310 Series XPS v4 Windows x64 4 Lexmark
    Lexmark MS310 Series Class Driver Windows x64 4 Lexmark
    Lexmark CX825 Series Class Driver Windows x64 4 Lexmark
    Kyocera CS 4053ci XPS Windows x64 4 Kyocera
    HP PCL3 A-size Printer Class Driver Windows x64 4 HP
    HP OfficeJet Pro 9020 series PCL-3 Windows x64 4 HP
    HP OfficeJet Pro 8740 PCL-6 Windows x64 4 hp
    HP OfficeJet Pro 7740 series PCL-3 Windows x64 4 HP
    HP LaserJet 400 M401 PCL6 Class … Windows x64 4 HP
    HP LaserJet 200 color M251 PCL6 … Windows x64 4 HP
    HP ENVY Pro 6400 series PCL-3 Windows x64 4 HP
    HP Color LaserJet MFP M480 PCL-6… Windows x64 4 hp
    HP Color LaserJet A3/11×17 PCL6 … Windows x64 4 HP
    Canon Office XPS Class Driver Windows x64 4 Canon
    Sharp MX-3500N Windows x64 3 Sharp
    Microsoft Shared Fax Driver Windows x64 3 Microsoft
    Microsoft enhanced Point and Pri… Windows x64 3 Microsoft
    Lexmark MS310 Series v2 XL Windows x64 3 Lexmark
    Kyocera ECOSYS P3045dn KX Windows x64 3 Kyocera
    Kyocera CS 4053ci KX Windows x64 3 Kyocera
    HP LaserJet 1022n Windows x64 3 HP
    Generic / Text Only Windows x64 3 Generic
    Canon Generic Plus PCL6 Windows x64 3 Canon
    Microsoft enhanced Point and Pri… Windows NT x86 3 Microsoft

    Here’s the log file:

    Windows PowerShell transcript start
    Start time: 20231207151958
    Username: WORKGROUP\SYSTEM
    RunAs User: WORKGROUP\SYSTEM
    Configuration Name:
    Machine: CBTS-LT2 (Microsoft Windows NT 10.0.22621.0)
    Host Application: powershell.exe -executionpolicy bypass -file .\add_printers.ps1
    Process ID: 19176
    PSVersion: 5.1.22621.2506
    PSEdition: Desktop
    PSCompatibleVersions: 1.0, 2.0, 3.0, 4.0, 5.0, 5.1.22621.2506
    BuildVersion: 10.0.22621.2506
    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/3] Adding inf file C:\Windows\IMECache\e6f14f43-785c-46f6-9415-9a0ccfdd8812_1\Sharp\EnglishA\PCL6\64bit\su2emenu.inf
    [2/3] Adding inf file C:\Windows\IMECache\e6f14f43-785c-46f6-9415-9a0ccfdd8812_1\Sharp\EnglishA\PPD\64bit\SU2JJENU.INF
    [3/3] Adding inf file C:\Windows\IMECache\e6f14f43-785c-46f6-9415-9a0ccfdd8812_1\Sharp\EnglishA\PS\64bit\su2hmenu.inf

    [Add printerdriver(s) to Windows]
    [1/1] Adding printerdriver SHARP MX-3071S PCL6
    Add-PrinterDriver : The specified driver does not exist in the driver store.
    At C:\Windows\IMECache\e6f14f43-785c-46f6-9415-9a0ccfdd8812_1\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:\Windows\IMECache\e6f14f43-785c-46f6-9415-9a0ccfdd8812_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 Sharp MX-3071S
    WARNING: Port for Printer Sharp MX-3071S already exists, removing existing port and printer first
    Set-PrintConfiguration : The specified printer was not found.
    At C:\Windows\IMECache\e6f14f43-785c-46f6-9415-9a0ccfdd8812_1\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:\Windows\IMECache\e6f14f43-785c-46f6-9415-9a0ccfdd8812_1\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: 20231207152022

    I guess I’ll try it with the driver you downloaded. I hope the Dutch thing won’t be an issue lol. I’ll post my results after testing.

    • What does pnputil.exe /enum-drivers | Select-String Sharp give you? Just to be sure if the driver is or is not installed on the system. Add-PrinterDriver makes it available from the driverstore to use with installing a printer.

      • So it worked with the Dutch version of the driver. However, all the wording is in Dutch lol. I was able to modify the link you downloaded the Dutch version of the drive to replace Dutch with English and now I’m going to try that. If that doesn’t work then I’ll run the pnputil.exe command you proposed. Standby

  41. Thank you very much for this, it works perfectly and very well explained, how can we thank you for this?!
    A small problem arised for my canon printer: how can I add additional configoption to retreive device settings automatically? Or otherwise force to use department ID’s?

      • Thank you for your answer! Which registry import should I exactly take after adding the printers?
        Perhaps I didn’t make myself clear, sorry. In my school we work with department ID’s on our Canons to identify the teacher using the printer. When installing the printers with your scripts, the setting for department ID’s is off, but is should be on. Of course the teachers can do this manually, but I was wondering if that is something that can be set through the configoptions in your script. The setting is turned on also if in Device settings the device information dat is not set to manually, but automatically retreived.

      • I don’t know what, it was a suggestion 😅 I understand your issue, but I don’t have a standard option for that. The cmdlets for setting things like color and flip page etc. are limited…

      • Ah okay, I see ;-)! No problem, I’ll make a nice howto for my teachers. Thanks again for this great post!!

Leave a Reply to endpointadminCancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.