Home > Mac administration, macOS, payload-free_package_printer_generator, Scripting > Generating printer configurations using payload-free_package_printer_generator.sh

Generating printer configurations using payload-free_package_printer_generator.sh

As part of a recent discussion, a colleague posted in the MacAdmins Slack that they needed to deploy printers as part of a DeployStudio workflow. DeployStudio doesn’t natively include this functionality, so that meant developing a way to deploy the desired printers to the appropriate Macs via one of the following methods:

As part of the conversation, I pointed to Nick McSpadden‘s PrinterGenerator tool:


Nick’s tool is designed to create printer configurations for deployment via Munki. However, my colleague wasn’t using Munki in this case and didn’t plan to deploy it. So even though there was a tool that could have solved the problem, adapting it to work for my DeployStudio-using colleague’s needs was going to take some time and effort.

The discussion got me started thinking about the problem of printer deployments and ways to solve it that could work for the vast majority of deployment solutions. After some research and testing, I’ve developed a solution that may work for most deployment needs. For more details, see below the jump.

My solution was to build a script named payload-free_package_printer_generator.sh, which does three tasks:

  1. Accept printer configuration input.
  2. Use that input to generate a script which uses the lpadmin tool to create printers with the provided configuration information.
  3. Generate a payload-free package to run the script.

Running the script


/path/to/payload-free_package_printer_generator.sh -n -l -d -a -p -1 -2 -3 -4 -5 -6 -7 -8 -9 -c


  • -n: Name of the print queue. May not contain spaces, tabs, # or / characters. (required)
  • -l: The physical location of the printer. Examples may include Reception Desk, Librarian’s Office or Second Floor, Room 2C456 (optional)
  • -d: The printer name which is displayed in the Printers & Scanners pane of System Preferences, as well as in the print dialogue boxes. (required)
  • -a: The IP or DNS address of the printer. Protocol must be specified as part of the address (for example, use lpd://ip.address.goes.here or lpd://dns.address.goes.here for LPR printing.) (required)
  • -p: Name of the driver file in /Library/Printers/PPDs/Contents/Resources/. This must use the full path to the drive (starting with /Library). (required)
  • -1: Specify first printer option. (optional)
  • -2: Specify second printer option. (optional)
  • -3: Specify third printer option. (optional)
  • -4: Specify fourth printer option. (optional)
  • -5: Specify fifth printer option. (optional)
  • -6: Specify sixth printer option. (optional)
  • -7: Specify seventh printer option. (optional)
  • -8: Specify eighth printer option. (optional)
  • -9: Specify ninth printer option. (optional)
  • -c: Name of the Apple Developer ID Installer certificate being used to sign the payload-free package. Certificate name should be formatted like Developer ID Installer: Your Name or Developer ID Installer: Your Name (F487797D). (optional)

Note: This script needs to be run with root privileges.


To create an unsigned payload-free package using only the required printer configuration options, run the command shown below with root privileges:

/path/to/payload-free_package_printer_generator.sh -n PrinterQueueGoesHere -d PrinterNameGoesHere -a lpd://ip.address.goes.here -p /Library/Printers/PPDs/Contents/Resources/PrinterDriverPPDHere.gz

Screen Shot 2017 07 18 at 3 32 45 PM

The script’s output should appear similar to that shown below:

The script will generate a postinstall script that looks like this:

Once the postinstall script has been created, a payload-free package will be generated using the script. Once the package has been generated, a new Finder window will appear to show the completed package’s location.

Screen Shot 2017 07 18 at 3 40 46 PM

If you need to sign the payload-free package, that is possible using the -c option. For example, you may need to create a signed package that sets up a printer with the following settings:

Printer Queue Name:  ReceptionDeskBrotherLaserPrinter
Printer Location:  Reception Desk
Printer Display Name:  Reception Desk Brother Laser Printer
Printer Address:  lpd://
Printer Driver:  /Library/Printers/PPDs/Contents/Resources/Brother HL-2170W series CUPS.gz

To create an signed payload-free package which can create this printer, run the command shown below with root privileges:

/path/to/payload-free_package_printer_generator.sh -n ReceptionDeskBrotherLaserPrinter -l "Reception Desk" -d "Reception Desk Brother Laser Printer" -a lpd:// -p "/Library/Printers/PPDs/Contents/Resources/Brother HL-2170W series CUPS.gz" -c "Developer ID Installer: Rich Trouton (XF95CST45F)"

Screen Shot 2017 07 18 at 3 25 00 PM

You may be prompted to authorize access to your Developer ID certificate.

Screen Shot 2017 07 18 at 3 24 30 PM

Once authorized, the package will be generated.

Screen Shot 2017 07 18 at 3 25 43 PM

You can verify that the package is signed by clicking on the padlock icon in the Installer window.

Screen Shot 2017 07 18 at 3 25 48 PM

Screen Shot 2017 07 18 at 3 25 52 PM


To test a payload-free package generated by this script, take it to a Mac which does not already have the desired printer set up on it and run the installer package.

Note: The appropriate printer drivers must be installed prior to setting up the printer. If not, the lpadmin tool which is used by the payload-free package to set up the printer will generate an error and the installer package will report a failed install.

Screen Shot 2017 07 18 at 3 26 01 PM

Screen Shot 2017 07 18 at 3 26 24 PM

Screen Shot 2017 07 18 at 3 26 26 PM

The printer should be set up as specified.

Screen Shot 2017 07 18 at 3 26 44 PM

Screen Shot 2017 07 18 at 3 26 55 PM

Screen Shot 2017 07 18 at 3 26 58 PM

The script is available below. It is also available from GitHub at the following address:


  1. Vince
    July 21, 2017 at 4:54 pm

    Could this be implemented with a payload of drivers to install first and then run this script to install the printers? Is it possible to specify a default printer from this script as well?

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: