I wrote a script to rewrite the computer name. We're using Enterprise Connect, and I have a bash script that's deployed (pkg) to /Library/Scripts/ec, and then gets executed to write the computer name to /tmp/ecUser:
#!/bin/bash
echo $1 > /tmp/ecUser
exit 0;
Here's the script that gets executed, per policy:
#!/bin/bash
if [ ! -f /tmp/ecUser ];
then
jamfUser=$( echo $3 | sed 's/./-/g' )
/usr/sbin/scutil --set ComputerName $jamfUser
/usr/sbin/scutil --set LocalHostName $jamfUser
/usr/sbin/scutil --set HostName $jamfUser
echo $jamfUser
else
ecUser=$( cat /tmp/ecUser | sed 's/./-/g' )
/usr/sbin/scutil --set ComputerName $ecUser
/usr/sbin/scutil --set LocalHostName $ecUser
/usr/sbin/scutil --set HostName $ecUser
echo $ecUser
fi
exit 0;
Here is the result from the policy, in this case the username is coming from /tmp/ecUser, which is matt.marshall, rewritten to be matt-marshall:
Executing Policy e Change Computer Name
Running script Change Computer Name...
Script exit code: 0
Script result: matt-marshall
matt-marshall
Checking for patches...
No patch policies were found.
Running Recon...
Retrieving inventory preferences from https://jss.iterable.zone/...
Locating accounts...
Searching path: /Applications
Locating package receipts...
Locating plugins...
Locating printers...
Gathering application usage information...
Now, everything is working as expected, except that JSS doesn't seem to get updated with the new computer name despite it getting the correct name.
Any ideas what's happening?
Note - reset computer name to Jamf Pro record is not checked.