Skip to main content

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

 

 

@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?



@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?



Here are the three we have that we’ve successfully used this script with:

Brother MFC-L9670CDN

Brother HL-L2360D

Brother HL-L5100DN


Thank you very much for sharing your solution. I work at a special needs school without about 110 staff MacBooks and have been attempting to create a script to deploy our AirPrint printers. I am logged in as root on my MacBook and testing the ipp2ppd command with some of our AirPrint printers, before I create the script in Jamf. However, it never returns, and the ppd and log files remain zero length. Do you have any suggestions for why ipp2ppd might not exit? Here is what I entered for one of our AirPrint printers:

/System/Library/Printers/Libraries/ipp2ppd ipp://10.10.1.4/ipp/print "" > /private/tmp/printer_driver1.ppd

Thank you for taking the time to read my question.

- Peter Dearstyne


Thank you very much for sharing your solution. I work at a special needs school without about 110 staff MacBooks and have been attempting to create a script to deploy our AirPrint printers. I am logged in as root on my MacBook and testing the ipp2ppd command with some of our AirPrint printers, before I create the script in Jamf. However, it never returns, and the ppd and log files remain zero length. Do you have any suggestions for why ipp2ppd might not exit? Here is what I entered for one of our AirPrint printers:

/System/Library/Printers/Libraries/ipp2ppd ipp://10.10.1.4/ipp/print "" > /private/tmp/printer_driver1.ppd

Thank you for taking the time to read my question.

- Peter Dearstyne


Is it possible that your Mac and the printer aren’t on the same network or are perhaps on different VLANS? It would definitely fail if that were the case.


@john_sherrod 

 

We’re trying to deploy some airprint printers in our district, but we’re receiving the following error.  I’m assuming it’s a formatting issue.

Script exit code: 2

Script result: Generating PPD file for printer at 10.18.71.114...
/Library/Application Support/JAMF/tmp/AirPrint - School 114: HP 3201: line 16: syntax error near unexpected token `then'
/Library/Application Support/JAMF/tmp/AirPrint - School 114: HP 3201: line 16: `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 '

Error running script: return code was 2.

 

Here is the exact code we’re using.  Any help would be appreciated. 

 

#!/bin/bash 
# Adds a printer via AirPrint.
# Author: John William Sherrod - jwsherrod@mac.com # Version 1.0: 02-20-2025

## EDIT THE Following items to deploy printer

PRINTER_IP="10.18.71.114"
PRINTER_NAME="School 114: HP 3201"
PRINTER_LOCATION="School 114: HP 3201"
PRINTER_DISPLAY_NAME="School 114: HP 3201"
PPD_PATH="/private/tmp/School_Printer.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

 


Are we sure that the computer and the printer on the exact same network? The Mac running the script has to be able to query the printer directly. So if they’re on different networks that can’t talk to each other it will fail in this way.


These devices were on the same network yeah.  It looks like we were able to get it working, not using your script, but at least it’s working for us now. 

Thank you for your reply.


Glad you found a way to get it working!