Yosemite setComputerName change won't stick

beneb
New Contributor III

Hi:

Working with 10.10.1 and 10.10.2, Casper 9.63. From Terminal, locally on a machine, I'm running sudo jamf setComputerName -name "Name". Then I'll run sudo jamf recon. Just after, in Terminal (via scutil --get HostName/LocalHostName/ComputerName) and in System Prefs "Sharing" the new name is good. As soon as I reboot the machine, the old name comes back. Why won't the name change stick? Has anyone seen this or have a fix for it? Thanks

*Edit: I now realize I should've posted initially that the machine was imaged via Target Disk Mode and Casper Imaging 8.63 before it was migrated to our 9.63 JSS. This may or may not be part of the issue, still to be determined.

11 REPLIES 11

htse
Contributor III

I've found that setting the Computer Name locally, just gets erased the next time that Casper enforces it's will. So to correct computer names, I correct them in JSS and use the Reset Computer Names option through Casper Remote.

beneb
New Contributor III

Thanks for the suggestion. Part of the reason that I was running recon directly after the local name change was to update the name in the JSS right away. That way, if the JSS was going to enforce its will, it would already be the correct name. Regardless, I tried your suggestion and had the JSS change the name via policy and the "Reset Computer Name" flag in the JSS. I verified that the name change was good (sort of, see note below), however after rebooting, the old name came back again.

One other thing that I did notice was the built-in "Reset Computer Name" via policy did not change the "HostName" (only changed the LocalHostName and ComputerName) whereas if you run it via command line "jamf setComputerName -name Name" it changes all three. I'm not sure if this is a bug or which option is the desired behavior.

jacob_salmela
Contributor II

I have always used this script and it still seems to still work well on 10.10:

#!/bin/bash
# Bonjour name ending in .local
scutil --set LocalHostName "My-iMac"
# Friendly name shown in System Preferences > Sharing
scutil --set ComputerName "My-iMac"
# The name recognized by the hostname command
scutil --set HostName "My-iMac"
# Save the computer's serial number in a variable so it can be used in the next command.
serialNum=$(ioreg -l | awk '/IOPlatformSerialNumber/ { split($0, line, """); printf("%s
", line[4]); }')
# Set the NetBIOS name as the serial number
defaults write /Library/Preferences/SystemConfiguration/com.apple.smb.server NetBIOSName -string "$serialNum"
jamf recon

beneb
New Contributor III

Thanks for all the suggestions. After further testing it does not appear to be related to Casper at all. I've done the above script (thanks jacob) and removed Casper from the mix altogether. I've removed the machine from the network as well and it still reboots with the old name. Here's my steps taken and it still reboots with the old name:

disconnect the network
sudo scutil --set LocalHostName "NewName"
sudo scutil --set HostName "NewName"
sudo scutil --set ComputerName "NewName"
sudo scutil --get LocalHostName (to verify new name has taken hold)
sudo scutil --get HostName (to verify new name has taken hold)
sudo scutil --get ComputerName (to verify new name has taken hold)
killAll cfprefsd
reboot

After this, it still boots with the old name and subsequent scutil get commands report the old name for all entries.

Thanks again all, will post if I find out more.

mattstocum
New Contributor III

I'm bumping up against the same problem. I think Casper is somehow involved though. ComputerName sticks if I set it before enrolling, but not after. The only profiles I have on the machine after enrolling are the Casper generated MDM profile, and a local CA for some self-signed certs. Also, if I set the computer name in Casper, then force it down using Casper Admin, the name seems to stick, but if I wait for the next time jamf recon runs, Casper will pull the incorrect name from the client.

mattstocum
New Contributor III

Just as a test, I just ran this right after enrolling the computer in Casper. There is only a few seconds between each command. Casper seems to be doing something that resets the computer name after only a few seconds.

MacTest3:~ root# scutil --get ComputerName
MacTest3
MacTest3:~ root# scutil --set ComputerName MacTest4
MacTest3:~ root# scutil --get ComputerName
MacTest4
MacTest3:~ root# scutil --get ComputerName
MacTest3
MacTest3:~ root# jamf setComputerName -name "MacTest5"
Set Computer Name to MacTest5
MacTest3:~ root# scutil --get ComputerName
MacTest5
MacTest3:~ root# scutil --get ComputerName
MacTest3
MacTest3:~ root#

mattstocum
New Contributor III

I think I found a workaround:

# kill jamf daemon because it is resetting the computer name
launchctl unload -w /Library/LaunchDaemons/com.jamfsoftware.jamf.daemon.plist 
/usr/sbin/jamf setComputerName -name "${COMPUTERNAME}"

# Check in with JSS to update computer name record
/usr/sbin/jamf recon

launchctl load -w /Library/LaunchDaemons/com.jamfsoftware.jamf.daemon.plist

beneb
New Contributor III

Hi Matt:

What version is your JSS? Did you image the machine with Casper Imaging? Just curious. While this machine was on a 9.63 JSS during the problem and subsequent troubleshooting, I think it might have been imaged via Target Disk Mode from a 8.73 JSS and Casper Imaging and then migrated over to the 9.63 JSS. I'm wondering if the problem is originating in there somehow. More testing and moving away from 8.73 as soon as feasible.

mattstocum
New Contributor III

I'm using 9.63, and I do not use Casper Imaging at all. We just have a policy triggered by a custom event that installs the software we need.

beneb
New Contributor III

Hi Matt:

I couldn't get your fix to work unfortunately. As soon as I reboot the machine name goes back. This is now happening on all of our 10.10 machines...strange indeed.

mattstocum
New Contributor III

@bbyleen][/url do you by any chance have a policy that's triggered on networkStateChange that resets the computer name? I think that was my issue. It looks like changing the computer name gets interpreted as a network state change, which was resetting the computer name. Once I took that out the name change seemed to stick without any of my other hacks.