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. Thank you for providing this excellent tutorial.
    May I seek your assistance? I am encountering the issue where the application is not detected after a successful installation (Error 0x87D1041C), although the printer is installed. I have verified that the printer name is correctly populated, as per your previous comment in the detection script. Despite republishing the Intune file and associating it with the w32app, I am still encountering the error message. Could you please help?

      • Harm, thank you for your response. Indeed I didn’t upload the new
        detection.ps1 to the app in Intune.

  2. Hi Harm, we are moving from a print server to Azure Universal print. Now users are still using the ‘ old’ printers on their systems. I want to remove the ‘ old’ printers to get them use the Universal print printers. Do you also have a script which retrieves all installed printers and printer drivers on Intune managed devices? I expect we will see different drivers 🙁

    • Don’t have anything for that (yet), but what you could do is run a script that detects printers that were using the print server and removes all that were found. Something like this should work:

      Get-Printer | Where-Object ComputerName -eq ‘Printservername’ | Remove-Printer -Confirm:$false

      Drivers shouldn’t matter anymore if you’re using Universal Print right?

      • Unfortunately I get errors on some devices when the detection and remediation scripts are running on user devices.

        Remove-Printer : Access was denied to the specified resource. At C:\WINDOWS\IMECache\HealthScripts\1597f1b0-1e1c-424e-a5ea-e675e3e89366_3\remediate.ps1:2 char:60 + … Object PortName -eq “192.168.35.242” | Remove-Printer -Confirm:$false + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : PermissionDenied: (MSFT_Printer (N… = 0, Type = 0):ROOT/StandardCimv2/MSFT_Printer) [R emove-Printer], CimException + FullyQualifiedErrorId : HRESULT 0x80070005,Remove-Printer

        I run the scripts using the logged-on credentials.
        Is there a way to force the removal of the printers even the user doesn’t have the rights?

  3. I have been trying to get this running but cannot even get off the mark. The Intune package installs but the scripts do not start. I see the installer script is allowing the Add_Printers.ps1 to run but it seems to not launch (Win 11 23H2) because it doesn’t start it doesn’t even create the log.

    I originally made the script for three Kyocera printers but when i had issues I started again and just set it up for one.

    Not sure why I cannot get it running.

    • If it doesn’t even create the logfile… Then the script doesn’t start, Start-Transcript is the first thing is does (Logging to c:\windows\temp). The Intune package shouldn’t install because the detection would fail afterwards, there are no errors in Intune stating that?

      • Hi Harm, This is the strange part my Intune policy shows “Installed” 1 and is Blue so everything looks great.

        CND0183MD9
        admin@DomainName.com
        Windows 10.0.22631.3007
        1.2
        Installed
        31/01/2024, 10:14:38

        I go onto the machine and check devices and printer and nothing is there so I check company portal and that shows the package as installed. I then head over to C:\Windows\Temp looking for “printers.log” but nothing there. I then attempt a restart but no difference.

        I have install.cmd as…
        powershell.exe -executionpolicy bypass -file .\Add_Printers.ps1

        Then Add_Printers.ps1 as…

        Start-Transcript -Path c:\windows\temp\printers.log
        #Read Printers.csv as input
        $Printers = Import-Csv .\Printers.csv -Delimiter ‘;’

        #Add all printer drivers by scanning for the .inf files and installing them using pnputil.exe
        $infs = Get-ChildItem -Path . -Filter “*.inf” -Recurse -ErrorAction SilentlyContinue | Select-Object -ExpandProperty Fullname

        $totalnumberofinfs = $infs.Count
        $currentnumber = 1
        Write-Host (“[Install printer driver(s)]`n”) -ForegroundColor Green
        Foreach ($inf in $infs) {
        Write-Host (“[{0}/{1}] Adding inf file {2}” -f $currentnumber, $totalnumberofinfs, $inf) -ForegroundColor Green
        try {
        c:\windows\sysnative\Pnputil.exe /a $inf | Out-Null
        }
        catch {
        try {
        c:\windows\system32\Pnputil.exe /a $inf | Out-Null
        }
        catch {
        C:\Windows\SysWOW64\pnputil.exe /a $inf | Out-Null
        }
        }
        $currentnumber++
        }

        #Add all installed drivers to Windows using the CSV list for the correct names
        $totalnumberofdrivers = ($printers.drivername | Select-Object -Unique).count
        $currentnumber = 1
        Write-Host (“`n[Add printerdriver(s) to Windows]”) -ForegroundColor Green
        foreach ($driver in $printers.drivername | Select-Object -Unique) {
        Write-Host (“[{0}/{1}] Adding printerdriver {2}” -f $currentnumber, $totalnumberofdrivers, $driver) -ForegroundColor Green
        Add-PrinterDriver -Name $driver
        $currentnumber++
        }

        #Loop through all printers in the csv-file and add the Printer port, the printer and associate it with the port and set the color options to 0 which is black and white (1 = automatic and 2 = color)
        $totalnumberofprinters = $Printers.Count
        $currentnumber = 1
        Write-Host (“`n[Add printer(s) to Windows]”) -ForegroundColor Green
        foreach ($printer in $printers) {
        Write-Host (“[{0}/{1}] Adding printer {2}” -f $currentnumber, $totalnumberofprinters, $printer.Name) -ForegroundColor Green
        #Set options for adding printers and their ports
        $PrinterAddOptions = @{
        ComputerName = $env:COMPUTERNAME
        Comment = $Printer.ART
        DriverName = $Printer.Kyocera TASKalfa 4053ci KX
        Location = $Printer.HQ
        Name = $Printer.ART
        PortName = $Printer.10.98.76.152
        }

        $PrinterConfigOptions = @{
        Color = $True
        DuplexingMode = 'TwoSidedLongEdge'
        PrinterName = $Printer.Name
        }

        $PrinterPortOptions = @{
        ComputerName = $env:COMPUTERNAME
        Name = $Printer.Name
        PrinterHostAddress = $Printer.PortName
        PortNumber = '9100'
        }

        #Add Printerport, remove existing one and the corresponding printer if it already exists
        if (Get-PrinterPort -ComputerName $env:COMPUTERNAME | Where-Object Name -EQ $printer.Name) {
        Write-Warning ("Port for Printer {0} already exists, removing existing port and printer first" -f $printer.Name)
        Remove-Printer -Name $printer.Name -ComputerName $env:COMPUTERNAME -Confirm:$false -ErrorAction SilentlyContinue
        Start-Sleep -Seconds 10
        Remove-PrinterPort -Name $printer.Name -ComputerName $env:COMPUTERNAME -Confirm:$false
        }

        #Add printer and configure it with the required options
        Add-PrinterPort @PrinterPortOptions
        Add-Printer @PrinterAddOptions -ErrorAction SilentlyContinue
        Set-PrintConfiguration @PrinterConfigOptions
        $currentnumber++

        }
        Stop-Transcript

        That script calls Printers.csv which i have as…

        Name;DriverName;PortName;Comment;Location
        ART;Kyocera TASKalfa 4053ci KX;10.98.76.152;ART;HQ

        Then detection should run which I have as…

        $printers = @(
        ‘ART’
        )
        #Check every printer if it’s installed
        $numberofprintersfound = 1
        foreach ($printer in $printers) {
        try {
        Get-Printer -Name $printer -ErrorAction Stop
        $numberofprintersfound++
        }
        catch {
        “Printer $($printer) not found”
        }
        }
        #If all printers are installed, exit 0
        if ($numberofprintersfound -eq $printers.count) {
        write-host “($numberofprintersfound) printers were found”
        exit 0
        }
        else {
        write-host “Not all $($printers.count) printers were found”
        exit 1
        }

        The Intune setup is just as per the guide. Have I missed loads of sections out on the script that I needed to edit?

      • You changed the PrinterAddOptions in Add_Printers.ps1 to this:
        #Set options for adding printers and their ports
        $PrinterAddOptions = @{
        ComputerName = $env:COMPUTERNAME
        Comment = $Printer.ART
        DriverName = $Printer.Kyocera TASKalfa 4053ci KX
        Location = $Printer.HQ
        Name = $Printer.ART
        PortName = $Printer.10.98.76.152
        }

        You should leave them as:

        $PrinterAddOptions = @{
        ComputerName = $env:COMPUTERNAME
        Comment = $Printer.Comment
        DriverName = $Printer.DriverName
        Location = $Printer.Location
        Name = $Printer.Name
        PortName = $Printer.Name
        }

        It uses the fields from the .csv

      • Hi Harm, I finally got some time back on this and took the advice from your reply. Having overengineered your script, I started again from scratch. I tested the script by manually running it, and it worked perfect. I have just headed over to Intune and created a new .intunewin file. The first rollout has been a success, so I am pushing it to another test machine now. I really appreciate your reply to my issues Harm, so thank you.

  4. Hello Harm,
    Thanks again for putting this together. Can you point me in the direction to find out how I can set the following print options for a printer:

    paper size ArchD
    Rotate 90 degress
    Landscape
    roll size 36″

    I assume I would need a separate/dedicated Intune package for this printer otherwise all the printers will have these print options?

    Thanks in advance,
    Dan

  5. Thanks Harm.

    I receive an error;

    [Add printer(s) to Windows]
    [1/] Adding printer
    PS>TerminatingError(Add-PrinterPort): “Cannot validate argument on parameter ‘Name’. The argument is null or empty. Provide an argument that is not null or empty, and then try the command again.”
    Add-PrinterPort : Cannot validate argument on parameter ‘Name’. The argument is null or empty. Provide an argument that
    is not null or empty, and then try the command again.
    At C:\Windows\IMECache\1c67cf74-6ec7-4a3e-ab86-6ed856dd8fa7_1\add_printers.ps1:67 char:21
    + Add-PrinterPort @PrinterPortOptions

    &

    TerminatingError(Set-PrintConfiguration): “Cannot validate argument on parameter ‘PrinterName’. The argument is null or empty. Provide an argument that is not null or empty, and then try the command again.”
    Set-PrintConfiguration : Cannot validate argument on parameter ‘PrinterName’. The argument is null or empty. Provide an
    argument that is not null or empty, and then try the command again.
    At C:\Windows\IMECache\1c67cf74-6ec7-4a3e-ab86-6ed856dd8fa7_1\add_printers.ps1:69 char:28
    + Set-PrintConfiguration @PrinterConfigOptions
    + ~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : InvalidData: (:) [Set-PrintConfiguration], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationError,Set-PrintConfiguration
    Set-PrintConfiguration : Cannot validate argument on parameter ‘PrinterName’. The argument is null or empty. Provide
    an argument that is not null or empty, and then try the command again.
    At C:\Windows\IMECache\1c67cf74-6ec7-4a3e-ab86-6ed856dd8fa7_1\add_printers.ps1:69 char:28
    + Set-PrintConfiguration @PrinterConfigOptions

    The CSV is as follows;

    Name; Drivername:Portname:Comment:Location
    Ricoh;Ricoh IM C2000 PCL 6; 192.168.2.30; Company;Office

    What am I doing wrong?

  6. Thanks for this, Im running into an error, the Add_printers.ps1 is looking for the the printers.csv in System32 for some reason? Error message below.

    Import-Csv : Could not find file ‘C:\WINDOWS\system32\printers.csv’.
    At C:\Users\Gary\My Drive\Barnes wiki\Intune\Printers\Printers\Add_Printers.ps1:3 char:13
    + $Printers = Import-Csv .\printers.csv -Delimiter ‘;’
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : OpenError: (:) [Import-Csv], FileNotFoundException
    + FullyQualifiedErrorId : FileOpenFailure,Microsoft.PowerShell.Commands.ImportCsvCommand

    No changes have been made to your script on this

    Start-Transcript -Path c:\windows\temp\printers.log
    #Read printers.csv as input
    $Printers = Import-Csv .\printers.csv -Delimiter ‘;’

    • The printers.csv should be in your Intune package, how does the folder look that you use to create to Intunewin file from? If you just run the script in ISE or VSCode, please change directory to C:\Users\Gary\My Drive\Barnes wiki\Intune\Printers\Printers first because it expects the .csv file in your current directory

  7. Hello,

    I have a problem when deploying through Intune. I always encounter an issue. Intune indicates that the installation was not necessary. Therefore, an error is displayed on the PCs, and I cannot proceed with the PC.

    How can I resolve this issue?

  8. Any idea what am i doing wrong ? I made no changes to the script, running it in a test environment and this is what i get.

    C:\temp\PrinterIntune\AddPrinterIntune>powershell.exe -executionpolicy bypass -file .\add_printers.ps1
    Transcript started, output file is c:\windows\temp\printers.log
    [Install printer driver(s)]

    [1/3] Adding inf file C:\temp\PrinterIntune\AddPrinterIntune\Canon\CNP60MA64.INF
    [2/3] Adding inf file C:\temp\PrinterIntune\AddPrinterIntune\HP\hpcu250u.inf
    [3/3] Adding inf file C:\temp\PrinterIntune\AddPrinterIntune\TOSHIBA\esf6u.inf

    [Add printerdriver(s) to Windows]
    [1/3] Adding printerdriver TOSHIBA Universal Printer 2
    Add-PrinterDriver : The specified driver does not exist in the driver store.
    At C:\temp\PrinterIntune\AddPrinterIntune\add_printers.ps1:33 char:5
    + Add-PrinterDriver -Name $driver
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : NotSpecified: (MSFT_PrinterDriver:ROOT/StandardCimv2/MSFT_PrinterDriver) [Add-PrinterDri
    ver], CimException
    + FullyQualifiedErrorId : HRESULT 0x80070705,Add-PrinterDriver

    • I think “TOSHIBA Universal Printer 2” is not the name like it it in the esf6u.inf? Could you check the installed driver in your Print Server properties to get the complete driver list and the correct Display Name.

      • Harm, this is the content of the file. This is happening to all the 3 printers that come with the script.

        No changes were made in any files.

        ; Copyright (c) 2020 Toshiba Tec Corporation, All Rights Reserved.
        ; Delta: 4835

        [Version]
        Signature=”$Windows NT$”
        Provider=%TOSH%
        ClassGUID={4D36E979-E325-11CE-BFC1-08002BE10318}
        Class=Printer
        CatalogFile=eSf6u.cat
        DriverVer=06/02/2020,7.212.4835.17
        DriverIsolation=2

        [Manufacturer]
        %TOSH%=TOSHIBA,NTamd64,NTamd64.6.0

        [TOSHIBA]
        “TOSHIBA Universal Printer 2” = install_pre_vista,TOSHIBATOSHIBA_Unive5D6E,1284_CID_TS_PCL6_Color
        “TOSHIBA Universal Printer 2” = install_pre_vista,USBPRINT\TOSHIBAe-STUDIO6550CD363
        “TOSHIBA Universal Printer 2” = install_pre_vista,USBPRINT\TOSHIBAe-STUDIO6540C1332
        “TOSHIBA Universal Printer 2” = install_pre_vista,USBPRINT\TOSHIBAe-STUDIO5540C1376
        “TOSHIBA Universal Printer 2” = install_pre_vista,USBPRINT\TOSHIBAe-STUDIO5055C4F24
        “TOSHIBA Universal Printer 2” = install_pre_vista,USBPRINT\TOSHIBAe-STUDIO4555C4119
        “TOSHIBA Universal Printer 2” = install_pre_vista,USBPRINT\TOSHIBAe-STUDIO4540CD34B
        “TOSHIBA Universal Printer 2” = install_pre_vista,USBPRINT\TOSHIBAe-STUDIO3555C81AC
        “TOSHIBA Universal Printer 2” = install_pre_vista,USBPRINT\TOSHIBAe-STUDIO3540C13FE
        “TOSHIBA Universal Printer 2” = install_pre_vista,USBPRINT\TOSHIBAe-STUDIO3055C4FAC

  9. Problem solved. I think the script will not run if the system is not up to date.
    Get-PrinterDriver was not working properly. After windows updates, Get-PrinterDriver started working and script installing the printers.
    Thank you.

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