Computer Name Change

geo52geo
New Contributor

How do you change the name of a computer in the JSS?

Signed,

Newbie

10 REPLIES 10

Not applicable

Typically I would use ssh and scutil to accomplish this. You could make a policy with "reset computer names" checked off under "Advanced", change the name of the computer in the JSS under a machine's "Computer Information", then execute the policy. I find this to be a bit too roundabout when I have ssh to work with.

Reset the Computer Name:
sudo scutil --set ComputerName samplecomputername

Reset the Local Host Name: sudo scutil --set LocalHostName samplelocalhostname

Reset the Host Name (if applicable):
sudo scutil --set HostName samplehostname

You can also use scutil --get to check each value after you set them.

Then run a "jamf recon" command and you will see that the machine's name has updated in the JSS.

pearlin
New Contributor III

Find the computer you want to rename the Inventory (General Information, hit the edit button, change the Computer Name and hit save).

You can then scope a policy to rename the client to reflect the entry in the JSS. Create a policy and go to "Maintenance" and check the box for "Reset Computer Names." Set the policy to run once per computer and on however many triggers you like.

GabeShack
Valued Contributor III

The problem with the above from Pearlin, is that if the machines in question check in during the time you wait to do the 2nd step it will overwrite what you just changed in the jss back to the original name thereby making this process a loop of madness.

This could be a great feature request though:
What should happen is when you change the name in the JSS it should send a command to the target computer immediately to reset the computer name to what is in the JSS. This keeps from creating too many steps.

Gabe Shackney
Princeton Public Schools

Gabe Shackney
Princeton Public Schools

pearlin
New Contributor III

Gabe's right. You sometimes get stuck in a stare down with machines that report an inventory before the policy runs and then have to start all over again. Not a big deal if it's just a handful (it's still annoying), but wouldn't be fun in the tens, hundreds, or thousands of computers.

As for that Feature Request: https://jamfnation.jamfsoftware.com/featureRequest.html?id=2190

Go vote it up!

GabeShack
Valued Contributor III

LOL I made a feature request as well. Hopefully they combine them...

Gabe Shackney
Princeton Public Schools

Gabe Shackney
Princeton Public Schools

pearlin
New Contributor III

I saw that, so I changed the link to point to yours. After all, it was your idea.

Chris_Hafner
Valued Contributor II

I use the following when it comes up (assuming that my computer name is good).

#!/bin/sh

scutil --set LocalHostName $(scutil --get ComputerName)
scutil --set HostName $(scutil --get ComputerName)

exit 0

Of course, the real question has to do more with how you "want" to set your computer names. You do have to put something in somewhere.

tyro
New Contributor

we used to have

$JAMF setComputerName --useSerialNumber

but Sierra does not like it.

shall we use

sudo scutil --set ComputerName --useSerialNumber

?

FeasiblePear
New Contributor III

What I do is post a Policy in Self Service that is on all computers but limited to my Techs LDAP grouping. This policy contains a custom script that asks the Tech to input the new computer name, Sets it correctly on the computer, then I have it run inventory. This works really well as not all my techs have visibility into our JAMF Pro. Here is the script:

!/bin/bash

Created by FeasiblePear

COMPUTERNAME=$(/usr/bin/osascript << EOT
tell application "Finder" activate display dialog "Enter the Computer Name, please." default answer "" set COMPUTERNAME to the (text returned of the result)
end tell
EOT)

Set Computer, LocalHost, and HostName from Tech's input

/usr/sbin/scutil --set ComputerName $COMPUTERNAME
/usr/sbin/scutil --set LocalHostName $COMPUTERNAME
/usr/sbin/scutil --set HostName $COMPUTERNAME
dscacheutil -flushcache

Exit

exit 0

ronhun1
New Contributor II

Since i like using the serial number i do this

set the trigger to before then create an AD Bind trigger and set that to set after

!/bin/bash

Last 8 characters of the Serial Number:

definedComputerName="/usr/sbin/system_profiler SPHardwareDataType | awk '/Serial Number/ { print $NF }' | rev | cut -c 1-8 | rev"

/usr/sbin/scutil --set ComputerName ${definedComputerName}
/usr/sbin/scutil --set LocalHostName ${definedComputerName}
/usr/sbin/scutil --set HostName ${definedComputerName}

exit 0