Hi Everyone,
I have a policy that runs a script which grabs a users full name, splits it into 2 (first and last) and puts a . in between and then appends the domain name. The issue is that when the policy runs off of a trigger, it grabs "System" as the first name and "Administrator" as the last name. However, when I run the policy manually by running "sudo jamf policy" in terminal, it grabs the correct first and last name and the username is then inputted correctly.
#!/bin/sh
# Get the logged in users First and Last name
firstName=$(dscl . -read "/Users/$(who am i | awk '{print $1}')" RealName | sed -n 's/^ //g;2p' | cut -d' ' -f1)
lastName=$(dscl . -read "/Users/$(who am i | awk '{print $1}')" RealName | sed -n 's/^ //g;2p' | cut -d' ' -f2)
domain="@domainname.com"
userEmail=$firstName.$lastName$domain
echo "$userEmail"
#example userEmail: first.last@domainname.com
# Run recon, submitting the users username which as of 8.61+ can then perform an LDAP lookup
sudo jamf recon -endUsername $userEmail
exit 0