Last active
July 9, 2024 19:30
-
-
Save PinkShellos/49d1fc6413ecc9b5cc6a581475e7c43b to your computer and use it in GitHub Desktop.
Mac MDM Printer Deployment Script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/zsh | |
# Printer installation script | |
displayName="" # Spaces OK | |
printerName=$(sed 's/ /_/g' <<< "$displayName") # NO SPACES, changes to underscores | |
printerModel="" | |
serverAddr="" | |
protocol="" # [ socket (HP Jetdirect) | ipp | lpd | smb ] | |
printerAddr="$protocol://$serverAddr/$printerName" | |
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 variable is null, use command without it | |
if [[ "$opts" == '' ]]; then | |
/usr/sbin/lpadmin -p "$printerName" -D "$displayName" -v "$printerAddr" -m "$printerModel" -P "$PPDfile" -L "$officeLoc" -o printer-is-shared=false -o auth-info-required=username,password -E | |
else | |
/usr/sbin/lpadmin -p "$printerName" -D "$displayName" -v "$printerAddr" -m "$printerModel" -P "$PPDfile" -L "$officeLoc" "$opts" -o printer-is-shared=false -o auth-info-required=username,password -E | |
fi | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ppdOptionsDiff.command documentation:
https://www.brunerd.com/blog/2012/03/13/getting-and-setting-ppd-options-via-command-line-for-use-with-lpadmin-in-os-x/