Posted on 05-01-2017 12:36 PM
I'd like to send out a script that will change the computer name from "Jane's MacBook Air" to her short name, which we have configured to look like 21smithj.
I know that I can update those names on systems sending out a script, but how to do I get that to reflect inside the JSS? Does that happen automagically? My fear is that it will revert to the previous name during the next check-in or inventory.
Is there a way to avoid that?
Thank you.
Posted on 05-01-2017 12:39 PM
the JSS will reflect the name change after the next inventory.
Posted on 05-01-2017 01:11 PM
This is the script I use.
#!/bin/sh
username=`ls -l /dev/console | cut -d " " -f 4`
scutil --set ComputerName "$4""$username"
scutil --set HostName "$4""$username".<domain>
scutil --set LocalHostName "$4""$username"
jamf recon
Posted on 05-03-2017 02:34 PM
Question do you have a script that works asking the user or tech to type in a unique Hostname which for the life of me cannot be automated if im correct?
Posted on 05-03-2017 05:22 PM
This is the script I used in the past that prompted the techs to input the new computer name.
CD="/Applications/Utilities/cocoaDialog.app/Contents/MacOS/cocoaDialog"
rv=($("$CD" standard-inputbox --title "Computer Name" --no-newline --informative-text "Enter the Computer Name (Based on your Naming Convention)" --value-required))
COMPNAME=${rv[1]}
sudo scutil --set ComputerName $COMPNAME
sudo scutil --set LocalHostName $COMPNAME
sudo scutil --set HostName $COMPNAME
tb=`"$CD" ok-msgbox --text "Computer name updated!"
--informative-text "The computer's hostname has been added to $COMPNAME."
--no-newline --float`
if [ "$tb" == "1" ]; then
echo "User said OK"
jamf setComputerName -name "$COMPNAME"
elif [ "$tb" == "2" ]; then
echo "Canceling"
exit
fi
Posted on 07-18-2018 10:34 AM
@kbingham That script seems simple enough. Can you explain it to me? My end goal is to change the name of the mac in those three places, but use the already existing asset tag name that is filled into the asset field in Jamf Pro. Right now, only the name of the Mac is changing and I'm having problems with users trying to log in with their AD accounts. These Macs are bound to AD. I believe the issue is occuring because the NetBIOS name is the same on all the macs that are having issues with logging in.
Posted on 07-18-2018 10:48 AM
I use The MUT when changing multiple device names its really a breeze, has saved me tons of hours!
https://www.jamf.com/jamf-nation/third-party-products/620/the-mut?view=info
Posted on 07-18-2018 10:59 AM
@RalphyIT one thing to note when changing computer names with MUT it simply updates the name in Jamf, and doesn't actually push that down to the device itself. It will change back on next inventory update. You can use the "Reset Computer Name" option for policies (Policies > New > Maintenance > Reset Computer Name) which will take the name from Jamf and actually apply it to the computer. I actually also like to use a very similar script to what @kbingham left above, just a simple scutil for the various names.
MUT works fantastic for Mobile Device names, but that's because it actually issues an MDM command to set and enforce the name upon running, which is not something that's possible at this time via the API (to my knowledge) without generating a policy with the payload mentioned above.
Posted on 07-18-2018 10:59 AM
Is there a way for me to remote wipe a Mac but keep the name intact for me to identify after the wipe?
Thank you
(New to JAMF)
Posted on 08-15-2018 01:11 PM
In the script by kbingham (thank you - nice work), I do not want the username selected but serial number used. What is the option to do that?
I ran the script, but it grabbed root as the name (did the script prior to a user logging in) and I do not want the name to change if another user (like our IT staff) logs in.
I found the answer by DHowel (I believe)
SERIALNUMBER=ioreg -l |grep IOPlatformSerialNumber | awk '{print $4}' | cut -d " -f 2
This will pull up serial number.
So with this I will make the changes to the script. Thank you ALL!