Find computers with Sharing > Printer Sharing checked

kwsenger
Contributor

Looking for an Extension Attribute to determine if a Mac has Sharing > Printer Sharing is checked.

Current Process:
We currently send this command using Casper Remote to individual computers when needed to turn off printer sharing. We could create a policy to run this each week but are looking for something more automated.
[cupsctl --no-share-printers]

Ideal Process:
Have an Extension Attribute which identifies computers that have Printer Sharing checked and add this device to a Smart Computer Group. A policy would be created scoped to this smart group which would run the command [cupsctl --no-share-printers] under Files and Processes.

Any suggestions are appreciated?
Thank you,

Karl Senger
Systems Engineer
School District of Milton
Milton, WI

1 ACCEPTED SOLUTION

davidacland
Honored Contributor II

Using cupsctl this should do the job:

#!/bin/sh

printerSharingStatus=`cupsctl | grep "_share_printers=" | sed 's/_share_printers=//g'`

if [ $printerSharingStatus == 0 ]; then
echo "<result>Disabled</result>"
else
echo "<result>Enabled</result>"
fi

exit 0

Call it something like "Printer Sharing Status" and it will say whether it is enabled or disabled.

View solution in original post

5 REPLIES 5

davidacland
Honored Contributor II

Using cupsctl this should do the job:

#!/bin/sh

printerSharingStatus=`cupsctl | grep "_share_printers=" | sed 's/_share_printers=//g'`

if [ $printerSharingStatus == 0 ]; then
echo "<result>Disabled</result>"
else
echo "<result>Enabled</result>"
fi

exit 0

Call it something like "Printer Sharing Status" and it will say whether it is enabled or disabled.

mm2270
Legendary Contributor III

Another possible way is to look for "Browsing On" or "Browsing Off" in the cupsd.conf file.

#!/bin/sh

echo "<result>$(awk '/Browsing/{print $2}' /private/etc/cups/cupsd.conf)</result>"

It should report "On" or "Off"

EDIT- Never mind the above. Looks like that may only show if the general printer sharing option is enabled, but not whether any printers are actually checked to be shared out. It may also report as On if the machine is connected to someone elses remotely shared printer, so false positives.
Use what davidacland posted above instead.

kwsenger
Contributor

This script as an Extension Attribute worked perfectly.
Extension Attribute used as the criteria in a Smart Computer Group.
Policy scoped to this Smart Computer group, with this "Execute Command" "cupsctl --no-share-printers; sudo jamf recon"

The computer falls right out of the Smart Computer group.

KCH080208
New Contributor II

@sengerk i was just looking into this. What does this look like in the JSS? Did you use @davidacland script or how did you put the script as an extension attribute?

KCH080208
New Contributor II

nevermind i got it all figured out. Thanks for the helpful information.