yesterday
I recently spent some time working on a script to deploy AirPrint printers as we’ve got a few of them on our campus that don’t have driver support from the manufacturer, meaning AirPrint is the only option. I wanted to share what I’ve come up with in case anyone else is in need of this.
All you have to do is change the details in the “Printer details” section at the top of the script to match your printer’s IP address, location, and display name. I’d also recommend modifying the PPD path slightly to give it a more specific name than just printer_driver.ppd. Example: break_room_printer_driver.ppd.
Note: For this to work, the Mac needs to be on the same network as the printer since it queries the printer to gather the information to create the PPD file.
The result is that you can deploy an AirPrint printer to your Macs via Jamf Pro complete with the icon and everything!
#!/bin/bash
# Adds a printer via AirPrint.
# Author: John William Sherrod - jwsherrod@mac.com
# Version 1.0: 02-20-2025
# Printer details
PRINTER_IP="111.11.11.11"
PRINTER_NAME="Printer_Name" # Name that will appear in the printer list
PRINTER_LOCATION="Printer Location" # Location description
PRINTER_DISPLAY_NAME="Printer Display Name" # Friendly display name
PPD_PATH="/private/tmp/printer_driver.ppd" # Location of PPD
# Create PPD using ipp2ppd with error handling
echo "Generating PPD file for printer at $PRINTER_IP..."
if ! /System/Library/Printers/Libraries/ipp2ppd "ipp://$PRINTER_IP/ipp/print" "" > "$PPD_PATH" 2> /tmp/ipp2ppd_error.log; then
echo "Error: Failed to generate PPD file. Check printer IP or IPP service availability."
if [ -s /tmp/ipp2ppd_error.log ]; then
echo "Details: $(cat /tmp/ipp2ppd_error.log)"
fi
rm -f /tmp/ipp2ppd_error.log # Clean up error log
exit 1
fi
# Check if the PPD file exists on the system
if [ ! -f "$PPD_PATH" ]; then
echo "Please deploy the PPD file first. Exiting."
exit 1
fi
# Check if printer already exists
if lpstat -p | grep -q "$PRINTER_NAME"; then
echo "Printer '$PRINTER_NAME' already exists. Skipping installation."
exit 0
fi
# Add the printer using lpadmin
# -P specifies the PPD to provide the printer's icon, deployed from Jamf Pro via a package
# -v specifies the device URI using the IP address
# -E enables the printer and accepts jobs
/usr/sbin/lpadmin -p "$PRINTER_NAME" \
-L "$PRINTER_LOCATION" \
-D "$PRINTER_DISPLAY_NAME" \
-v "ipp://$PRINTER_IP/ipp/print" \
-P "$PPD_PATH" \
-E \
-o printer-is-shared=false
# Verify installation
if [ $? -eq 0 ]; then
echo "Successfully added printer '$PRINTER_NAME' at IP $PRINTER_IP"
# Set as default printer (optional - comment out if not needed)
# /usr/sbin/lpadmin -d "$PRINTER_NAME"
else
echo "Failed to add printer '$PRINTER_NAME'"
exit 1
fi
exit 0
yesterday
@john_sherrod Thank you for sharing,
The script is very useful for the future,
can you add a list of printers that you have tested?
16 hours ago
Here are the three we have that we’ve successfully used this script with:
Brother MFC-L9670CDN
Brother HL-L2360D
Brother HL-L5100DN