remove current printers and deploy new ones

Dalmatian
Contributor

Hi All

how to remove current printers installed in macs, and deploy new ones into macs

thanks

7 REPLIES 7

jonnydford
Contributor II

To remove all printers:

#!/bin/sh

for printer in `lpstat -p | awk '{print $2}'`
do
echo Deleting $printer
lpadmin -x $printer
done

Dalmatian
Contributor

@jonnydford Hi Jonny
thanks for your script, i know this is perfect for removing all the current printer. but in this case, i need to deploy another policy to add the new printers after i delete them by using your script. so it's gonna be funny for some of the clients that fall into a circle of adding and deleting printers.

so what i prefer is put all the actions of removing the current and adding the new into single script. that would be perfect to me.

u have any idea?

CasperSally
Valued Contributor II

@Dalmatian create a policy that runs the script 'before' and then adds the printers. You can set the policy to run once, or at reboot ongoing, etc

Dalmatian
Contributor

@CasperSally Hi Sally

could you explain the script "before"?

thanks

dgreening
Valued Contributor II

If you deployed the prior printers via the JSS, you can keep the prior ones in your deployment policy, but select "unmap" to remove the specific printers which you want to remove. In the same policy you can "map" the new printers.

CasperSally
Valued Contributor II

add the script to casper admin. In the script properties, make sure it's set to priority before.

add the printers you want to add to casper admin

set up a new policy in JSS.

add the script, add the printers, set scope and when/how often you want it to run. We do this same workflow for all of our student laptops in carts, etc.

jonnydford
Contributor II

It depends how you plan to deploy new printers, but we use a script to do it.

Assuming the driver is already on the Macs then at the end of the script you can add something like:

lpadmin -p NAME_OF_PRINTER -E -v lpd://ip.ad.dre.ss -P /Library/Printers/PPDs/Contents/Resources/driverpath.gz"