Made this since I couldn’t find anything in the worklets for printers from automox that didn’t need a print server.
Great for small-medium business’s that don’t use a print server. This script will allow you to install printers and there drivers without the need for a tech to manually touch and add the printers themselves.
I do recommend setting this as a policy on a manual run basis to only install the printers to someone’s computer that is missing them.
When creating the export files, I recommend creating them in a virtual machine with all built in printers and as many drivers that you can remove as possible. Create a checkpoint in that VM with the OS as clean as possible so you can restore this OS when you want to create a new file. Create the printers with the specific drivers, and preferences that you want and export them to a “.printerExport” file.
Make sure to test your exported file to make sure the file works correctly. I’ve seen drivers not like this printer export process and not function properly on import. Such as printers not restoring there print queues or printer preferences not importing when the process says it was successful. I usually try to stay and use only universal drivers personally to have as small as a file size as possible.
I’ve built this policy so you can upload as many different printer export files as you want and it will try to install them all.
This powershell script is for windows only.
#Created By: Brandon Dow
#Date Created: 19 November 2024 9:50AM ADT
#OS: Windows only, will fail if PrintBRM was removed from your system image (Tested on Windows 10 Pro, Windows 10 Enterprise, Windows 11 Pro, Windows 11 Enterprise)
#Date Modified:
#Version: 1.0.0
#Purpose: Automatically install all the printer files uploaded to this policy in automox to the computer(s) this policy is deployed to.
#Usage: You must have Print Management printer export files for this to work. The extensions of the files should be ".printerExport".
#Learn More: https://learn.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2012-r2-and-2012/jj134237(v=ws.11)
#Reason Modified:
#PrintBRM printer import issues found
# 1) You can't have spaces in the full path or the file name (cmd or powershell).
# 2) You must call the file name by it's full path (cmd or powershell).
# 3) You must call the application by it's full path (powershell only).
#PrintBRM application that is used for exporting and importing printer configuration files.
$PrintBRM = "$Env:SystemDrive:\Windows\System32\spool\tools\PrintBrm.exe";
#Directory where you want to set the printer file(s), fullpath must not have any spaces
$PrinterDirectory = "$Env:SystemDrive:\PrintersTemp";
#Create the temp directory that we know will work for the script.
If (!(Test-Path -Path "$PrinterDirectory"))
{
#Create Installation folder if it doesn't exist.
New-Item -ItemType "directory" -Path "$PrinterDirectory";
}
#Remove any previous temporary files
Remove-Item "$PrinterDirectory\*" -Recurse -Force;
#Move the printer files from the automox folder to the temp folder.
Move-Item -Path ".\*.printerExport" -Destination "$PrinterDirectory" -Force;
#Get the list of printer files fullname paths.
$PrinterFileList = (Get-ChildItem -Path "$PrinterDirectory\*.printerExport").FullName;
#If the printer file list is not empty than install the printers.
if ($PrinterFileList -ne $null)
{
#Foreach printer file found do the following
Foreach ($PrinterFile in $PrinterFileList)
{
#Install the printers from the configuration file. PrintBRM will skip the printer if one is already installed with the same name with this command. Add "-o force" to overwrite the currently installed printers.
$PrintBRMOutput = & "$PrintBRM" -r -f "$PrinterFile";
#Check if the installation was successfull
if ($PrintBRMOutput.Contains("Successfully finished operation."))
{
Write-Host "Successfully installed the printer(s) in the printer file: $PrinterFile.";
}
else
{
Write-Host "Failed to install the printer(s) in the printer file: $PrinterFile.";
Write-Host "Full Log Below";
Write-Host $PrintBRMOutput;
Write-Host "";
}
}
}
else
{
Write-Host "No printer file(s) found in policy.";
}