Posted on 02-15-2017 10:03 AM
Hello,
I am trying to figure out how I can rename the local computer names (ComputerName, LocalHostName, and HostName) to the current Computer ID currently set by AD bind on machine using bash or AppleScript.
Posted on 02-15-2017 11:28 AM
Untested, but this should do the trick. Note that the name in AD has a trailing $ .
#!/bin/bash
ad_name=$(/usr/libexec/PlistBuddy -c 'Print ":General Info:Computer Account"' /dev/stdin <<< $(/usr/sbin/dsconfigad -show -xml))
/usr/local/jamf/bin/jamf setComputerName -name ${ad_name}
Posted on 02-16-2017 06:29 AM
This should do the trick.
#!/bin/bash
ADCOMPUTERNAME=`dsconfigad -show | grep "Computer Account" | awk '{print $4}' | cut -d '$' -f 1`;
if [ "$ADCOMPUTERNAME" == "" ]; then
echo "Unable to determine computer name";
exit 1;
fi
echo "Setting computer name to: $ADCOMPUTERNAME";
/usr/local/bin/jamf setComputerName -name $ADCOMPUTERNAME
exit 0;