Skip to main content
Solved

Find computers with Sharing > Printer Sharing checked

  • December 12, 2014
  • 5 replies
  • 23 views

Forum|alt.badge.img+11

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

Best answer by davidacland

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.

5 replies

davidacland
Forum|alt.badge.img+18
  • Valued Contributor
  • 1811 replies
  • Answer
  • December 12, 2014

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
Forum|alt.badge.img+24
  • Legendary Contributor
  • 7886 replies
  • December 12, 2014

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.


Forum|alt.badge.img+11
  • Author
  • Contributor
  • 44 replies
  • December 17, 2014

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.


Forum|alt.badge.img+5
  • Contributor
  • 20 replies
  • January 20, 2015

@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?


Forum|alt.badge.img+5
  • Contributor
  • 20 replies
  • January 20, 2015

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