Email field update

brodeurm
New Contributor

I have a spreadsheet with machine name and serial number of machine.  Another field in the file is email address.  I want to find a way to update the User / EmailAddress field for each matching machine/serial number in Jamf database.   Can that be done and can someone show me the way?

1 ACCEPTED SOLUTION

damienbarrett
Valued Contributor
3 REPLIES 3

damienbarrett
Valued Contributor

bwoods
Contributor III

@brodeurm , I use the script below to update this information automatically as the machine is being configured via DEPNotify.

 

 

#!/bin/bash

# jamfProUserInfo.sh
# Brandon Woods
# June 2021
# This script locates the current user and updates Jamf Pro with user details

jamfBinary="/usr/local/bin/jamf"

currentUser=`python -c 'from SystemConfiguration import SCDynamicStoreCopyConsoleUser; import sys; username = (SCDynamicStoreCopyConsoleUser(None, None, None) or [None])[0]; username = [username,""][username in [u"loginwindow", None, u""]]; sys.stdout.write(username + "\n");'`

fullName=`dscl . -read /Users/$currentUser RealName | tail -1`

emailAddress="$currentUser@domain.com"

# Declare user details
echo $currentUser
echo $fullName
echo $emailAddress

# Set username in Jamf Pro
sudo $jamfBinary recon -endUsername "$currentUser"

# Set full name in Jamf Pro
sudo $jamfBinary recon -realname "$fullName"

# Set email address in Jamf Pro
sudo $jamfBinary recon -email "$emailAddress"

# Exit Script

exit 0		## Success
exit 1		## Failure

 

 

easyedc
Valued Contributor II

Are you using Microsoft 365 for your corp email? If so, you can query the system locally and get the account that activated the Office Suite (since that would hopefully be 1-1) and report that back as an EA, as well. 

#!/bin/zsh

#  Who Activated Office.sh
#
#  Created by Ed Corfman on 4/22/21.
#
## Query to get who activated the Office applications to hopefully turn it into a "who owns' this computer"

# Get the user
whodis=$( /usr/bin/stat -f "%Su" /dev/console )

# Check Office license
Activate=$(defaults read /Users/$whodis/Library/Preferences/com.microsoft.office.plist OfficeActivationEmailAddress)

# Did you get a real email address?
# No?
if [[ "$Activate" != *"@"* ]]; then
echo "<result>"Office is not activated"</result>"
    exit 0
# Yes?
else
# Send it back to Jamf
echo "<result>$Activate</result>"
fi

exit 0

 You can take that output and apply it to any EA you want or simply write it to the Email field. 

/usr/local/bin/jamf recon -email $Activate