Skip to main content
Question

DetectLocalAdmins.sh

  • November 15, 2011
  • 6 replies
  • 15 views

Forum|alt.badge.img+6

Tom Larkin was kind show a script that he was using to detect local admins on machines – I've run searches over at JAMF Nation – but haven't yet managed to find the script in the form that Tom displayed it in at JNUC. I have found the the script that returns a 1

Does anyone have a full version of the script that he was running?

Regards,
Matt Bentley

6 replies

rob_potvin
Forum|alt.badge.img+26
  • Employee
  • November 15, 2011

I second this :-)

Can't seem to find it either


Forum|alt.badge.img+31
  • Honored Contributor
  • November 15, 2011

this one?

#!/bin/bash

# extension attribute script to detect if a computer has a local admin
account on it with an UID of above 500 # # generate user list of users with UID greater than 500

userList=$(/usr/bin/dscl . list /Users UniqueID | /usr/bin/awk '$2 >
500 { print $1 }')

# now loop through results and test for membership of the admin group

for u in ${userList} ; do if [[ `/usr/bin/dscl . read /Groups/admin GroupMembership |
/usr/bin/grep -c ${u}` == 1 ]] then /bin/echo "<results>${u} is in the admin group</results>" else /bin/echo "${u} is not an admin.." fi done

copy/paste that into the JSS as an extension attribute and it should
work


Forum|alt.badge.img+24
  • Valued Contributor
  • November 15, 2011

JAMF Nation has a bug in it currently preventing me from posting my scripts because it kills tab formatting. Tom may be holding off for the same reason…

j
---
Jared F. Nichols
Desktop Engineer, Client Services
Information Services Department
MIT Lincoln Laboratory
244 Wood Street
Lexington, Massachusetts 02420
781.981.5436


Forum|alt.badge.img+31
  • Honored Contributor
  • November 15, 2011

No Tom is just lazy.....and my trip to Minneapolis landed me a cold. Looks like I had too much fun and a few too many IPAs.

:-)


Forum|alt.badge.img+12
  • Contributor
  • November 15, 2011

In the interests of skinning the cat multiple ways...here is one I whipped
up for someone on another list last week. Same basic idea.

Initialize array
get users > 500
check for NOT not an admin
add to array
print array

#!/bin/bash

list=()

for username in $(dscl . list /Users UniqueID | awk '$2 > 500 { print $1
}'); do if [[ $(dsmemberutil checkmembership -U "${username}" -G admin) !
*not* ]]; then list+=("${username}") fi
done

echo "result>${list[@]}</result"

Ryan M. Manly
Glenbrook High Schools


Forum|alt.badge.img+31
  • Honored Contributor
  • November 15, 2011

Having fun with functions?