Skip to content

Instantly share code, notes, and snippets.

@PeetMcK
Created July 15, 2021 23:54
Show Gist options
  • Save PeetMcK/f5631704431fbb8fe4d79fa93de13faa to your computer and use it in GitHub Desktop.
Save PeetMcK/f5631704431fbb8fe4d79fa93de13faa to your computer and use it in GitHub Desktop.
usage -- Get-LocalMembers GROUPNAME
# (usage -- Get-LocalMembers GROUPNAME)
Get-LocalMembers () {
if ! dscl . list /Groups/"$1" >> /dev/null 2>&1;then
echo "A Local Group with the name $1 does not exist."
exit 1
else
dscl . -list /Users | \
while read user
do printf "$user "
dsmemberutil checkmembership -U "$user" -G "$1"
done | grep "is a member" | cut -d " " -f 1;
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment