Creating a Smart group to find Local User Accounts that aren't company standard

sara_mccullar
New Contributor III

I am trying to create a smart group to find computers that have local user accounts that don't match the company standard user accounts. We have a specific format that our user accounts are so I need to be able to use wildcards.

3 REPLIES 3

curran
New Contributor III

Can you provide examples of what it should look like and an example of non-company standard?

sara_mccullar
New Contributor III

name.name is the company standard, anything not that would be non standard. 

karthikeyan_mac
Valued Contributor

You can use EA with script to find all the local users and match your criteria and report it back. Create smart group with criteria. 

#!/bin/bash
list=()
for username in $(dscl . list /Users UniqueID | awk '$2 > 500 && $2 < 1000 { print $1 }'); do
	if [[ $(dsmemberutil checkmembership -U "${username}" -G admin) != not ]]; then
		if [ ${username} does notmatches criteria ]; then #### add your criteria here in the if statement
			list+=("${username}")
		fi
	fi
done
echo "<result>${list[@]}</result>"

  Thanks