/build/static/layout/Breadcrumb_cap_w.png

How to install (and remove) a printer for Mac OSX using a K1000 script

Intro

I was curious the other day on what the command is in terminal to install a printer on a Mac since some of my customers don't give admin rights to their end users to change printer settings. 

Here is an example of installing a Dell 1765nfw printer to a Mac running Yosemite. 

Prerequisite


  1. Grab the driver from the manufacturer. You will need the .ppd.gz file format of the driver. 
    1. Example: Dell C1765nfw Color MFP.ppd.gz
    2. I pulled this driver from /Library/Printers/PPDs/Contents/Resources/ on a Mac that already had the printer installed

Instructions


  1. Create a new Online Kscript
  2. For Operating System, uncheck Select Specific Operating System and select Mac OSX
  3. Under Dependencies, upload your printer driver ppd.gz file
    1. rKLMee.png
  4. Add a New Task
  5. First step is copying the driver to the Printer PPD directory. 
  6. Under On Success - Launch  Program:
    1.  5pvfb0.png
    2. Directory: /bin/
    3. File: cp
    4. Parmeters: /Library/Application\ Support/Dell/KACE/data/kbots_cache/packages/kbots/130/Dell\ C1765nfw\ Color\ MFP.ppd.gz /Library/Printers/PPDs/Contents/Resources/
      1. *Change the number 130 to the ID of your script that gets made. (hover your mouse over the name of the script from the script list)
    5. Add another step underneath this one
    6. 7f8JZo.png
    7. Directory: /usr/sbin
    8. File: lpadmin
    9. Parameters-p Dell_C1765nfw_Color_MFP -L "Bruce's Office" -E -v lpd://10.0.0.3 -P "/Library/Printers/PPDs/Contents/Resources/Dell C1765nfw Color MFP.ppd.gz" -u allow:all
      1. Change the IP address to the IP of the printer. 
      2. -L is the location (Bruce's Office) which you can change in the command
      3. -u allow:all allows all  users to see and change the printer settings

Test and run the script to ensure it installs. It should pop right up in the Printers list even if you have it opened. 
ltgDY3.png

Removing a printer

This is an example of removing a specific printer. 

  1. Create a new Online Kscript
  2. For Operating System, uncheck Select Specific Operating System and select Mac OSX
  3. Add a New Task
  4. Under On Success - Launch  Program:
    1. VOdidv.png
    2. Directory/usr/sbin/
    3. File: lpadmin
    4. Parameters-x Dell_C1765nfw_Color_MFP
  5. If you need to get the name of the printer, you can just grab it from the Inventory of that Mac and replace it in the command above (minus the :idle part. That's the current status of the printer)
    1. OT4mZr.png


Comments

  • Rather than hardcoding the path to the ppd.gz file in step 4 you can use the $(KACE_DEPENDENCY_DIR) to specify the location. - chucksteel 8 years ago
    • I tried to do that, and since Application Support has a space in teh directory name, it didn't like that. I tried to put double quotes around the whole path, and it still didn't work. not sure why - brucegoose03 8 years ago
  • Also you should be careful with online scripts because if you run them on too many computers at the same time it can overwhelm the Kbox. You could probably convert this relatively easily to an offline script. Any reason you opted to go with the online approach? - Jbr32 8 years ago
    • Actually Offline scripts are worse when it comes to performance since the K1000's Konductor service can't control when when or what machiens it runs on in a throttled manner. Online Kscripts require the client be connected before it starts to run it, and can control when it uploads/downloads the bits between the two so it doesn't get overloaded. - brucegoose03 8 years ago
      • Really, I thought it was opposite. Thank you for sharing. - Jbr32 8 years ago
  • Nice write up, you beat me to it. I use this method and run the script to target a smart label which specifies all Macs that don't have the printer name listed in their inventory, and are part of specific security group device LDAP labels. These groups are people that sit in the general vicinity of the printers and who would ever need to use it. - bens401 8 years ago
  • Thank You very much. This is most helpful I tried pushing out the printers from the MacOS server we have setup for profile management and Apple Remote Desktop but since the drivers for the printers I needed to use were not part of MacOS it was installing them as generic.

    I used this to copy multiple driver files and install a total of 3 printers in one script for an art lab. The question I have is there a command line I can run to set a certain printer as default

    I am thinking I can run this command at the end of the script to set the printer I want as default.

    /usr/sbin/lpadmin -d printer - bwilkerson 8 years ago
    • Excellent! Glad it was helpful. Mission accomplished.
      Yep, that's the switch for setting it as a default. That could be part of the command you use when you install that particular printer. - brucegoose03 8 years ago
This post is locked
 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ