Worklet: Install Printers

Here’s a worklet that we use to install printers via Automox:

Eval Code:

$testFile = "$env:windir\InstalledPrinters.txt"
$testFileValue = (Test-Path $testFile)

if ($testFileValue -eq $true ) {
   Exit 0
} else { Exit 1 }

Remediation Code:

$testServer = "printserver"
$testServerValue = (Test-connection -Computername $testServer -BufferSize 16 -Count 1 -Quiet)

if ($testServerValue -eq $false ) {
   Exit 0
   Write-Host "printserver not reachable!"
   else {
			Add-Printer -ConnectionName "\\printserver\east-gray"
			Add-Printer -ConnectionName "\\printserver\west-color"
			New-Item -ItemType file "$env:windir\InstalledPrinters.txt"
1 Like

I’m getting flashbacks from managing printers at a previous company. Never again…

Your Worklet is so concise and simple. Love it

Thanks @EIT - I moved this into its own topic so it won’t get lost, and check your private messages for your link to redeem your mug.