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 🙂

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         = 0
        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 not enough) 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.

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

Leave a Reply

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