Posted on 01-10-2020 06:02 AM
If i change the name of the computer on the dashboard, will that propagate down to the machine in question? I looked thru several old posts pre 2016, and it looks like this was a change request. was it ever done?
Posted on 01-10-2020 07:24 AM
1/13/20 - Edit: My response is not completely true, @jimmy.vance from jamf posted a solution below that does exactly what danlaw777 was looking for.
Whatever the computer name is at the Computer level, it will reflect in Jamf.
For example If you changed the computer name in the Jamf Dashboard and it is different than what the computer is actually named, at the next check-in the Jamf Dashboard will revert to & or reflect the Computers Name.
You need to change the name of the computer at the computer level.
Posted on 01-10-2020 07:26 AM
I just found that out, i got impatient and named a mac with 2 different names and the 1 that was local took control.
now i just have to figure out a good way to write a script that will rename them .
Posted on 01-10-2020 07:37 AM
@danlaw777 you can start with this, it's all you need. the sudo jamf recon at the end of the script will update jamf after the computers renamed so it reflects the name change straight away
#!/bin/bash
ComputerName="NameHere"
scutil --set HostName $ComputerName
scutil --set LocalHostName $ComputerName
scutil --set ComputerName $ComputerName
sudo jamf recon
Posted on 01-10-2020 07:50 AM
does this prompt for end user input?
Posted on 01-10-2020 07:57 AM
No, it does not, are you seeking a user input text box for renaming?
Posted on 01-10-2020 08:07 AM
@danlaw777 heres a small applescript to get the job done
#!/usr/bin/osascript
set computername to text returned of (display dialog "Please type Computer Name" default answer "")
do shell script "sudo scutil --set HostName " & quoted form of computername
do shell script "sudo scutil --set LocalHostName " & quoted form of computername
do shell script "sudo scutil --set ComputerName " & quoted form of computername
do shell script "sudo jamf recon"
Posted on 01-10-2020 08:22 AM
im hoping to have minimal user input. my goal would be:
greetings, please input your 3 character location code: XXX
then the script takes that codeand adds the serial number at the end
ie: xxx-ewjfnwfnwen
once thats done run recon to update jamfpro
Posted on 01-10-2020 08:35 AM
this will do it @danlaw777
#!/usr/bin/osascript
set locationcode to text returned of (display dialog "Please input your 3 character location code." default answer "" with title ("Employee Location Code") with icon alias (POSIX file "/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/BookmarkIcon.icns") buttons {"Continue"} default button "Continue")
set serialnumber to do shell script "system_profiler SPHardwareDataType|grep 'Serial Number' -m1|cut -d: -f2|cut -c 2-13"
do shell script "scutil --set HostName " & quoted form of (locationcode & "-" & serialnumber)
do shell script "scutil --set LocalHostName " & quoted form of (locationcode & "-" & serialnumber)
do shell script "scutil --set ComputerName " & quoted form of (locationcode & "-" & serialnumber)
do shell script "sudo jamf recon"
Posted on 01-10-2020 08:49 AM
You can also lock the computer name via Jamf. If the Jamf binary sets the computer name it disallows the end user from changing it. I have modified Hugonauts script to make the change via jamf as well, which will prevent the name from being edited.
#!/usr/bin/osascript
set locationcode to text returned of (display dialog "Please input your 3 character location code." default answer "" with title ("Employee Location Code") with icon alias (POSIX file "/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/BookmarkIcon.icns") buttons {"Continue"} default button "Continue")
set serialnumber to do shell script "system_profiler SPHardwareDataType|grep 'Serial Number' -m1|cut -d: -f2|cut -c 2-13"
do shell script "scutil --set HostName " & quoted form of (locationcode & "-" & serialnumber)
do shell script "scutil --set LocalHostName " & quoted form of (locationcode & "-" & serialnumber)
do shell script "scutil --set ComputerName " & quoted form of (locationcode & "-" & serialnumber)
do shell script "sudo /usr/local/bin/jamf setComputerName -name" & quoted form of (locationcode & "-" & serialnumber)
do shell script "sudo jamf recon"
Posted on 01-10-2020 09:13 AM
i like that addition! very nice drtaru
Posted on 01-10-2020 10:16 AM
well, im not sure how i screwed it up, but when i run this, i dont get a prompt to insert the code, the only thing i see is that it runs, and then shows complete......
Posted on 01-10-2020 12:49 PM
You can make use of the Reset Computer Names option in the Maintenance payload in Computer Policies. As stated, it will "Change the computer name on computers to match the computer name in Jamf Pro." Hope that helps!
Posted on 01-10-2020 12:58 PM
this was perfect, no interaction needed! thanks !
Posted on 01-12-2020 09:44 PM
haha & here we are making little interactive applescripts & jamf has it all done already in the gui +1 to Jamf. learn something new everyday.
Posted on 01-13-2020 07:03 AM
all it takes is for some new guy who doesnt know his A$$ from a whole in the wall to ask!
Posted on 01-13-2020 07:51 AM
You can also use the Jamf Remote app to change names via JSS without pushing any policies which probably utilises same maintenance script.
1> First rename the device in your JSS.
2> Open the Jamf Remote app > Computers tab > find your device and ensure it is ticked.
3> Advanced TAB > Maintenance, tick the FIX computer Names box
4> Click Go
Posted on 01-13-2020 08:04 AM
We name all machines to their serial with the following script:
#!/bin/sh
#get serial number
serial=$(system_profiler SPHardwareDataType | awk '/Serial/ {print $4}')
# Set Hostname using variable created above
echo "Setting computer name to $serial locally..."
scutil --set HostName "$serial"
scutil --set LocalHostName "$serial"
scutil --set ComputerName "$serial"
exit 0
Posted on 01-13-2020 08:57 AM
Just keep in mind that if the Mac is in active directory that this Reset Names feature will not rename it in AD.
Posted on 01-13-2020 08:59 AM
i do, fortunately, we aren't binding our macs to AD
Posted on 01-16-2020 10:09 AM
@rpayne - that's a great one for when a client has no clue what they want to do! Which is often, or when there is no LDAP, etc.
Thanks for the post.