Skip to content

Instantly share code, notes, and snippets.

@talkingmoose
Last active September 15, 2024 18:42
Show Gist options
  • Save talkingmoose/4a2b613bf5273081459bc62c644193eb to your computer and use it in GitHub Desktop.
Save talkingmoose/4a2b613bf5273081459bc62c644193eb to your computer and use it in GitHub Desktop.
A Jamf Pro extension attribute to return whether a user account (hidden or visible) in a list of user accounts exists on a computer.
#!/bin/zsh
:<<ABOUT_THIS_EXTENSION_ATTRIBUTE
-----------------------------------------------------------------------
Written by:William Smith
Technical Enablement Manager
Jamf
[email protected]
https://gist.github.com/talkingmoose/4a2b613bf5273081459bc62c644193eb
Description: A Jamf Pro extension attribute to return whether a user account
(hidden or visible) in a list of user accounts exists on a computer.
Originally posted: September 15, 2024
Instructions:
1. In Jamf Pro, click Settings > Computer management > Extension attributes
and create a new extension attribute:
Display Name: "Existing user accounts"
Date Type: "String"
Inventory Display: "Extension Attributes"
Input Type: "Script"
2. Paste the entirety of this extension attribute script into the script
field.
3. Edit the list of management accounts below to include each user account
(one per line) you need to verify.
Except where otherwise noted, this work is licensed under
http://creativecommons.org/licenses/by/4.0/
"In too many organizations, the people at the top have all the
authority and none of the information, while the people on the
front line have all the information and none of the authority."
— Will Guidara
-----------------------------------------------------------------------
ABOUT_THIS_EXTENSION_ATTRIBUTE
# Edit this list to include each user account (one per line) you need to verify
managementAccounts="jamfadmin
jamfmdm
lapsadmin
mdmadmin
talkingmoose"
# Verify whether each user account exists and is hidden or visible
while IFS= read anAccount
do
# Read the details of an account
accountDetails=$( /usr/bin/dscl . read "/Users/$anAccount" 2>/dev/null )
# If an account exists, add its name to a list to report to Jamf Pro
# and report whether it's hidden
if [[ $accountDetails ]]; then
isHidden=$( /usr/bin/awk '/IsHidden/ { print " (Hidden)" }' <<< "$accountDetails" )
foundAccounts="$foundAccounts
$anAccount$isHidden"
fi
done <<< "$managementAccounts"
# Return the verified accounts to Jamf Pro
echo "<result>$( /usr/bin/sed '/^$/d' <<< "$foundAccounts" )</result>"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment