Lookup user information:
dscl . -read /Users/whotolookat NFSHomeDirectory Picture PrimaryGroupID UserShell UniqueID UserShell
Jamf Pro Extension Attribute
#!/bin/sh
actstatus=$(dscl . -read /Users/admin2lookat NFSHomeDirectory Picture PrimaryGroupID UserShell UniqueID UserShell)
if [ -z "$actstatus" ]
then
echo "admin2lookat Account Not Found "
else
echo "$actstatus "
fi
exit 0
reset user password
sudo dscl . passwd /Users/administrator 'thePa$$word'
Lookup all users:
dscacheutil -q user
Lookup a user (jdoe):
dscacheutil -q user -a name jdoe
lookup user shell
dscl . -read /Users/whotolookat UserShell
dscacheutil -q user | grep "name:" | grep -v '_'
Show User Accounts Only
dscl . list /Users | grep -v '_'
Show User id
id -u
Alternative Method: # Creates a list of local usernames with UIDs above 500 (not hidden)
/usr/bin/dscl /Local/Default -list /Users uid | /usr/bin/awk '$2 >= 501 { print $1 }'
scutil <<< "show State:/Users/ConsoleUser"
list all admin group users
dscl . -read /Groups/admin GroupMembership | grep "$USER" | awk '{ print $3 }'
| grep -v '_'
"No Standard users present":
#!/bin/zsh
results="No Standard users present"
users=($( dscl . -list /Users | grep -Ev '(_|daemon|nobody|root)' ))
for i in "${users[@]}"
do
is_admin=$( dseditgroup -o checkmember -m $i admin | awk '{ print $1 }')
echo $is_admin
if [[ $is_admin == 'no' ]]; then
results="Standard user present"
fi
done
echo "
************** List non standard users
#!/bin/zsh
results="No Standard users present"
users=($( dscl . -list /Users | grep -Ev '(_|daemon|nobody|root)' ))
for i in "${users[@]}"
do
is_admin=$( dseditgroup -o checkmember -m $i admin | awk '{ print $1,$2 }')
echo $is_admin | grep -v 'yes' | cut -d ' ' -f 2-
#if [[ $is_admin == 'yes' ]]; then
#results="Standard user present"
#fi
done
#echo "$reuslts"
**************
https://osxdaily.com/2016/07/05/list-user-accounts-command-line-mac/