Skip to content

Instantly share code, notes, and snippets.

@PinkShellos
Created May 8, 2024 16:26
Show Gist options
  • Save PinkShellos/49d1fc6413ecc9b5cc6a581475e7c43b to your computer and use it in GitHub Desktop.
Save PinkShellos/49d1fc6413ecc9b5cc6a581475e7c43b to your computer and use it in GitHub Desktop.
Mac MDM Printer Deployment Script
#!/bin/zsh
# Printer installation script for use with MDM
displayName="" # Spaces OK
printerName=$(sed 's/ /_/g' <<< "$displayName") # NO SPACES, change to underscores
printerModel=""
printerAddr=""
officeLoc=""
# opts is gathered from a computer with the printer installed using GUI and
# running ppdOptionsDiff.command script found in this blog post:
# https://www.brunerd.com/blog/2012/03/13/getting-and-setting-ppd-options-via-command-line-for-use-with-lpadmin-in-os-x/
opts=''
# PPD
PPDpath="/Library/Printers/PPDs/Contents/Resources"
PPD=""
PPDfile="$PPDpath/$PPD"
if [[ "$opts" == '' ]]; then
/usr/sbin/lpadmin -p "$printerName" -D "$displayName" -v "lpd://$printerAddr" -m "$printerModel" -P "$PPDfile" -L "$officeLoc" -o printer-is-shared=false -E
else
/usr/sbin/lpadmin -p "$printerName" -D "$displayName" -v "lpd://$printerAddr" -m "$printerModel" -P "$PPDfile" -L "$officeLoc" "$opts" -o printer-is-shared=false -E
fi
exit 0
@PinkShellos
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment