You can use JumpCloud Commands to deploy scripts and commands to help manage your devices. This article covers how to create a "Policy" using commands that can either add a new printer or delete an existing printer on macOS devices. See Get Started: Commands to learn more about commands.
Considerations:
- The command must be set to Run As root or a user with passwordless sudo access.
- Printer configurations vary by device and manufacturer and the following methods may not work in your specific environment. Consult with the printer manufacturer for best practices.
To grant a user passwordless sudo access, select Global Passwordless Sudo under the user's Details > User Security Settings and Permissions.
Adding a Printer
To add a new printer to a device, you will need:
- The printer name
- The IP or DNS address
- A path to the printer PPD file
- A description for the printer
Run the following command, substituting the name of printer, printer IP or DNS, path to PPD file, and description with your specifics:
/usr/sbin/lpadmin -p "name of printer" -E -v lpd://"printer IP or DNS"/"queue name" -P "path to PPD file" -D "description"
Example:
/usr/sbin/lpadmin -p "Brother" -E -v lpd://10.128.0.59/ -P /Users/rbalboa/Desktop/brother.ppd -D "Brother Color Printer"
Deleting a Printer
To delete the printer, you will need:
- The printer name
Run the following command, substituting the name of printer with your specifics:
/usr/sbin/lpadmin -x "name of printer"