Posted on 04-22-2014 04:04 PM
With VPP's requirement of all machines being tied to a computer, is there a way to change which user is assigned to a computer en masse? I see every "action" except for this.
Posted on 04-22-2014 05:55 PM
Well, on the machine itself, you can tell the JAMF Binary to run a recon, and specify the user who 'owns' the machine. In our case, we specify the user's username and an LDAP server to pull their info from:
jamf recon -endUsername auser -ldapServerID 1
Our environment names machines using their owner's username, so updating everyone was a simple matter of getting the computer name, trimming it with sed, and then using that to set the owner. If the mac has a non-standard name, we flag it via a Smart Group scoped to a ARD Field we check for. It's probably ugly, but it works:
#!/bin/sh
#First, get the computer name from JAMF
COMPUTERNAME=`jamf getcomputername`
echo "JAMF Reports $COMPUTERNAME as the name of this Mac"
#Clear ARD Fields
jamf setARDFields -target / -1 Hello
#Check That $COMPUTERNAME is a standard name that fits our filter
#Filter: -mac or -macX, then for -MAC or -MACX, then for TVs, then assume oddball.
if [[ $COMPUTERNAME == *-mac<* ]] || [[ $COMPUTERNAME == *-mac[0-9]<* ]];
then
#Trim string to username only
OWNER=`echo $COMPUTERNAME | sed -e 's|^.*>(.*)-.*$|1|'`
#Echo result to STDOUT
echo "My Scrying Script tells me $OWNER owns this Mac..."
#Set Scried owner as the Machine owner, via recon
jamf recon -endUsername $OWNER -ldapServerID 1
#Finally, echo some output so that we know what happened
echo "...so I set $OWNER as the owner of this Mac."
elif [[ $COMPUTERNAME == *-MAC<* ]] || [[ $COMPUTERNAME == *-MAC[0-9]<* ]];
then
#Trim string to username only
OWNER=`echo $COMPUTERNAME | sed -e 's|^.*>(.*)-.*$|1|'`
#Echo result to STDOUT
echo "My Scrying Script tells me $OWNER owns this Mac..."
#Set Scried owner as the Machine owner, via recon
jamf recon -endUsername $OWNER -ldapServerID 1
#Finally, echo some output so that we know what happened
echo "...so I set $OWNER as the owner of this Mac."
elif [[ $COMPUTERNAME == *-tv<* ]] || [[ $COMPUTERNAME == *-tv[0-9]<* ]];
then
#Machine is a Tableau TV - ignore!
echo "This machine is a TV. User should be set manually in JSS to maintainer of the TV."
jamf setARDFields -target / -1 TV
jamf recon
else
#The Machine has a non-standard name - don't change the owner!
echo "$COMPUTERNAME is an oddity - writing Oddball to ARD Field 1. Cursed be ye!"
#Set ARD Field 1 to Oddball, which adds machine to a SmartGroup, and Recon that to the JSS
jamf setARDFields -target / -1 Oddball
jamf recon
fi
exit 0
Posted on 04-23-2014 07:28 AM
I have a script that runs at each login. It captures the "current" user and fills it under "Location -> Username" and also so we can view the location history trails to see who have used the laptop in the past.
#!/bin/sh
#
#
#
/usr/sbin/jamf recon -endUsername $3