Export and install print drivers with Intune

Installing print drivers is a task we often find ourselves in, to enable printing from devices within an organization. If your infrastructure is relying on Intune for management of devices, there may not be a clear cut way to publish these drivers to devices. With the following method, we’re using PowerShell to export installed drivers from a device, and installing them using a VBS-script built-in in Windows client operating systems. Finally wrapping it all up in an exe-file for publishing to devices with Intune.

Assuming a device in your organization has verified drivers and printing capabilities to target printer, we can export the drivers from that device using PowerShell.

Export-WindowsDriver -Online -Destination C:\test

Finding the correct driver can be hard among all these exported drivers. The following PowerShell could help you identify the correct driver:

Get-WindowsDriver -Online | ?{$_.ClassName -eq "Printer"}

After finding the correct driver, we need to know which model we’re installing this driver for – and how that model is referred to by the driver. Open the .inf-file in the driver directory and look under “[Model]” – for example, this is how it looks for the Xerox WorkCentre 7220/7225-driver.

model

Knowing my model is 7225, I’ve identified the name as “Xerox WorkCentre 7225 V4 PCL6”. This is important for when we’re going to install the driver later on.
At this point, we need to zip up the files. Zip the driver directory so that the inf-file can be located with the path “driver.zip\driver\<INF-file>.inf”. This enables us to include the drivers within the exe-file and extract them to a set location (C:\temp\) on devices. Below is a VBS-script for extracting driver.zip to C:\temp\. Save it as “Unzip.vbs”.

Dim sCurPath, strFileZip
sCurPath = CreateObject("Scripting.FileSystemObject").GetAbsolutePathName(".")
strZipFile = sCurPath & "\driver.zip"
outFolder = "C:\temp\"
Set objShell = CreateObject( "Shell.Application" )
Set objSource = objShell.NameSpace(strZipFile).Items()
Set objTarget = objShell.NameSpace(outFolder)
intOptions = 256
objTarget.CopyHere objSource, intOptions

Our last piece of the puzzle is making a script that unzips the drivers and installs them on the system. Remember to modify the -m and -i parameters in the last command to reflect your model and your inf-file. Save the script as “script.bat”.

REM Making directory to place script and drivers in
md "C:\temp"

REM Extracting drivers to C:\temp\
Cscript .\Unzip.vbs

REM Installing driver using built-in VBS-script
Cscript %WINDIR%\System32\Printing_Admin_Scripts\en-US\Prndrvr.vbs -a ^
-m "Xerox WorkCentre 7225 V4 PCL6" ^
-i "C:\temp\driver\xeroxworkcentre7220_7225_pcl6.inf" ^
-h "C:\temp\driver\"

Using Windows’ built-in IExpress, we can wrap it all up in an exe-file. Remember to include all relevant files.

iexpress1

Configure the exe-file to launch the script.bat-file, which would extract the drivers and install them as explained earlier.

iexpress2

We’re now left with an exe-file for easy publishing to devices in Intune!

4 thoughts on “Export and install print drivers with Intune

  1. Jan says:

    Hi Eldar, thak you for the informative article.
    Do you know if it’s possible to manage drivers of other hardware on client station? Like, CPU, WLAN, GPU.. etc

    Thank you.

    Jan

  2. I see you don’t monetize your website, don’t waste your traffic, you can earn extra bucks
    every month because you’ve got hi quality content. If you want to know how to make extra money, search for:
    Boorfe’s tips best adsense alternative

Leave a Reply

Your email address will not be published. Required fields are marked *