Deploy a Printer with RMM | PowerShell



INTRO

Microsoft Windows Logo Curious Blue Background

If there’s one thing probably both IT professionals and users most likely have in common, it’s distain for printers. You would think by now everyone would be working on going paperless but apparently the trees aren’t worth the trouble, so we’re stuck with them. Installing printers in Windows has pretty much been the same since Windows Vista but for some reason people keep asking us to install them.

Printers are installed under the User Profile so when you install a printer for one user it doesn’t carry over to the rest of the users. However, in this guide since Datto RMM runs commands under SYSTEM, the printer installed will appear to all User Profiles in Windows.

PREPARING THE DRIVER PACKAGE

In this example, the printer I am installing is a Brother MFC-L3770CDW series printer. The driver can be downloaded here. You want to download the package titled, “Add Printer Wizard Driver”. Once downloaded I am presented with a file called, “Y17E_C1-hostm-D1.exe” which when ran extracts everything to a folder called “gdi” in the same directory. This directory will contain several .inf driver files for the printer. You will need to open each one with notepad to see which will be the correct one we push to computers for TCP/IP use.

In this case, look for the “Function” section near the top for help with some of them. There is a .inf file for just USB use, a scanner driver for USB/LAN use, and lastly a PlugAndPlay driver, which is the one we want which is named, “BRPRC17A.inf”. You will also need to record the correct name of the “DriverName” used in the .inf for the printer model you’re installing, in my case, a “Brother MFC-L3770CDW series” printer. If you do not do this, the script will not work and fail on port creation.

Now that we know the correct driver’s name and the file for installing for TCP/IP port use, you will need to create .ZIP archive of the driver files. You can’t just copy the .inf driver as it also has a corresponding .cat file needed for it, and also any other files that are in the folder needed for install. So, I create an archive of everything. You will then need to think about where you will extract the files on the remote Windows host as the script will be pointing to them.

POWERSHELL SCRIPT

Datto RMM will download the archive we created, PowerShell will then extract it, add the driver to the Windows Driver Repository, add a Printer Port that maps to the IP address of the printer, install the printer driver from the Windows Driver Repository via the DriverName in the .inf we recorded and use the correct path for that name, and then finally add the printer and map the driver and port together.

PowerShell
$ExecutingScriptDirectory = Split-Path -Path $MyInvocation.MyCommand.Definition -Parent

New-Item -Path 'C:\TEMP' -ItemType Directory
Expand-Archive -LiteralPath "$ExecutingScriptDirectory\Brother MFC-L3770CDW series.zip" -DestinationPath "C:\TEMP\Brother MFC-L3770CDW series"
PnPUtil /Add-Driver "C:\TEMP\Brother MFC-L3770CDW series\BRPRC17A.INF" /Install
Add-PrinterPort -Name "10.0.1.254_IP" -PrinterHostAddress "10.0.1.254"
Get-WindowsDriver -All -Online | Where-Object {$_.OriginalFileName -like '*BRPRC17A.INF'} | Select-Object -ExpandProperty OriginalFileName -OutVariable InfPath
Get-Content -Path $InfPath
Add-PrinterDriver -Name "Brother MFC-L3770CDW series" -InfPath $InfPath
Get-PrinterDriver
Add-Printer -DriverName "Brother MFC-L3770CDW series" -Name "Brother MFC-L3770CDW series" -PortName "10.0.1.254_IP"

CONCLUSION

Well, that’s about it. Remember, once installed all user accounts will be able to see it since it’s installed with SYSTEM permissions. I have used this method to deploy various models and brands of printers. When a user calls-in asking for a printer, I just deploy the job in Datto RMM and it’s done in minutes, I don’t even need to remote on and bother the user. It’s just done and works. It has saved me a lot of time and I hope it can for you as well!

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

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