Created
May 29, 2014 21:13
-
-
Save triti/a2c953516bac28315652 to your computer and use it in GitHub Desktop.
Outputs a comma-separated list of remote management users. For use as an Absolute Manage custom information field.
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
#!/bin/bash | |
# https://gist.github.com/a2c953516bac28315652 | |
# Based on Rich Trouton's script | |
# https://github.com/rtrouton/rtrouton_scripts/blob/master/rtrouton_scripts/check_for_remote_management_accounts/check_for_remote_management_accounts.sh | |
readonly ARD_ALL_LOCAL_USERS="$(/usr/bin/defaults read /Library/Preferences/com.apple.RemoteManagement ARD_AllLocalUsers)" | |
remote_management_users=() | |
if [[ "${ARD_ALL_LOCAL_USERS}" -eq 1 ]]; then | |
# Get all local user accounts with UIDs in the range of 500-1024 | |
IFS=$'\n' read -rd '' -a remote_management_users < <(/usr/bin/dscl . list /Users UniqueID | /usr/bin/awk '$2 >= 500 && $2 < 1024 { print $1; }') | |
else | |
# Get all user accounts that have explicit Remote Management rights | |
IFS=$'\n' read -rd '' -a remote_management_users < <(/usr/bin/dscl . list /Users naprivs | /usr/bin/awk '{print $1}') | |
fi | |
# Output to stdout a comma-separated list of the remote management users | |
(IFS=,; echo "${remote_management_users[*]}") | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment