Created
July 15, 2021 23:54
-
-
Save PeetMcK/f5631704431fbb8fe4d79fa93de13faa to your computer and use it in GitHub Desktop.
usage -- Get-LocalMembers GROUPNAME
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# (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