Delete all printers Self Service Policy fails with lpadmin "Unauthorized"

jperkins01
New Contributor

We are looking to blow away all printers via a Self Service policy so folks may re-download the proper printers that have been installed. Our students are not admins and i believe we do not allow them to delete printers via system preferences. Teachers are full admins but have rarely if ever have logged into a student computer to help elevate a permission. Anyone have ideas on how to accomplish this for a Self Service policy? We wish to get our clients helped out with cleaning up the old removed printers by deleting via a policy anyone may execute from Self Service. I have tried several scripts and unix commands at root from JSS but lpadmin almost always gives a "unauthorized" error in the JSS logs. I may run any of the scripts and unix commands locally and it just works! Stuck on the JSS deployment getting lpadmin "Unauthorized" errors!

1 ACCEPTED SOLUTION

stevevalle
Contributor III

I have a self service policy which runs the following command:

lpstat -p | cut -d' ' -f2 | xargs -I{} lpadmin -x {}

View solution in original post

4 REPLIES 4

pblake
Contributor III

Are you're scripts in self service running as root (sudo)?

jperkins01
New Contributor

echo "--Current printers"
lpstat -a | cut -d" " -f1 | while read PRTA
do
echo "-"$PRTA
done

lpstat -a | lpstat -a | cut -d" " -f1 | grep "xxxxx" | while read PRTB
do
echo "-- xxxxx printer detected attempting to delete: "$PRTB
lpadmin -x $PRTB
sleep 1
done

echo "--Remaining printers"
lpstat -a | cut -d" " -f1 | while read PRTC
do
echo "-"$PRTC
done

Tried this and other scripts but lpadmin get "Unauthorized", the "xxxxx" would be the name search for printers, it finds them but almost never deletes them due to "lpadmin "Unauthorized".
Also tried:
lpstat -p | cut -d" " -f2 | xargs -I{} lpadmin -x {} As a Files and Processes command with Root user, still get a "lpadmin unauthorized", lots of help here but none work 100% (https://jamfnation.jamfsoftware.com/discussion.html?id=11980).

pblake
Contributor III

https://jamfnation.jamfsoftware.com/discussion.html?id=8695

stevevalle
Contributor III

I have a self service policy which runs the following command:

lpstat -p | cut -d' ' -f2 | xargs -I{} lpadmin -x {}