I know you mentioned you checked your policies but do you happen to have a Login Window Config Profile?
In that Config Profile payload is an option to "Set Computer Name to Computer Record Name"
Also have a close look at your other Config Profiles as well. I have been bit a few times where JAMF deploys a config profile with a "hidden" unrelated setting and causes some havoc.
I think you will need to change the computer name with the jamf binary command instead.
jamf setComputerName -name "$ComputerName"
We use the following script
#!/bin/bash
NewComputerName="$(osascript -e 'Tell application "System Events" to display dialog "Enter the Asset ID Number:" default answer ""' -e 'text returned of result' 2>/dev/null)"
jamf setComputerName -name "$NewComputerName"
jamf recon -assetTag "$NewComputerName"
We do have a Login Window Config Profile! Thought for sure it would be this! But... verified that it is Not checked as well.
Verified the rest of our Config profiles as well. None of them have any settings for the name.
Going to RE-double check all of the policies again.
ammonsc - I'll give that a go and see if it holds any better for us.
@ammonsc I run the script locally and it works fine but it fails when deployed via policy or in SS any ideas?
Thanks!
@csanche3x , when running from a policy, the script is running as root, not as the local user, so the prompt is never shown to the use. Try this revised script:
#!/bin/bash
currentUser=$( scutil <<< "show State:/Users/ConsoleUser" | awk '/Name :/ && ! /loginwindow/ { print $3 }' )
NewComputerName="$(sudo -u $currentUser osascript -e 'Tell application "System Events" to display dialog "Enter the Asset ID Number:" default answer ""' -e 'text returned of result' 2>/dev/null)"
jamf setComputerName -name "$NewComputerName"
jamf recon -assetTag "$NewComputerName"
For more information, take a look at the JNUC presentation "Scripting Jamf: Best Practices" by Armin Briegel (scriptingosx). Here is a link his the resources page on his website ScriptingOSX-JNUC2020
@RBlount,Thank you very much for the script it's working as expected.
@RBlount
I put this script into Self Service and it seems to run just fine but there is nothing happening on the screen. Any idea what gives?
Never mind. Evidently it take a little bit!