Posted on 06-12-2014 02:28 PM
I'm assuming the best way to do this is through a postflight script?
I'm enrolling several Macs into my new JSS - not imaging at this time. I'd like to get the computers name updated before they bind to Active Directory. Any suggestions / examples would be much appreciated!
Posted on 06-12-2014 05:47 PM
/usr/sbin/scutil --set ComputerName InsertComputerNameHere
/usr/sbin/scutil --set LocalHostName InsertComputerNameHere
/usr/sbin/scutil --set HostName InsertComputerNameHere
Posted on 06-13-2014 08:33 AM
Hi calumhunter,
Can you send me the instruction on how to add this to my postflight script.
Thank You,
ArielN
Posted on 07-16-2014 08:11 PM
We usually let DNS handle the HostName, so the AD and Network groups don't jump up and down on us.
Posted on 07-25-2016 12:19 PM
I made a script that fires off at first login.
#!/bin/bash
# capture user input name
while true
do
name=$(osascript -e 'Tell application "System Events" to display dialog "Please enter a name for your computer" default answer ""' -e 'text returned of result' 2>/dev/null)
if [ $? -ne 0 ]
then # user cancel
exit
elif [ -z "$name" ]
then # loop until input or cancel
osascript -e 'Tell application "System Events" to display alert "Please enter a name or select Cancel!" as warning'
else [ -n "$name" ] # user input
break
fi
done
sudo scutil --set ComputerName $name
sudo scutil --set LocalHostName $name
sudo scutil --set HostName $name
sudo /usr/local/bin/jamf recon
Posted on 07-27-2016 04:00 PM
@adamlalicker We do something similar at Thin Provisioning time...mind if we steal some of your error handling? #tongueincheek
ComputerName=`/usr/bin/osascript <<EOT
tell application "System Events"
activate
display dialog "Enter Computer Name" default answer ""
set ComputerName to (text returned of result)
end tell
EOT`
/bin/mkdir -p /Library/Company
echo $ComputerName > /Library/Company/thin-provision-computer-name.txt
sudo scutil --set HostName $ComputerName
sudo scutil --set LocalHostName $ComputerName
sudo scutil --set ComputerName $ComputerName
Posted on 03-01-2019 02:08 PM
Question for anyone that can help. Is there a way to package this and make it part of the prestage enrollment package?
Posted on 03-01-2019 02:35 PM
Here is a script I wrote that you can run on the Enrollment trigger that will prompt for computer name during Setup Assistant. My workflow is to leave the machine on the Time Zone setup screen until the scripts run.
https://github.com/cwmcbrewster/Jamf_Scripts/blob/master/Computer_Enrollment_PromptForName.sh
Posted on 03-02-2019 08:32 AM
Cbrewer, nice idea! Timing is funny. I just spent all day creating a Ldaemon that detects if the signed in user is local vs domain. If domain user detected it auto renames and rebinds the machine to ad.
I like your idea, though. May try it.
Posted on 03-27-2019 09:45 AM
Cbrewer, great idea! A question though...
You say your workflow is to leave the machine on Time Zone setup screen until the script runs. How long does this usually take? I've set this to kick off on the Enrollment complete trigger, as the first of many actions that the Enrollment complete trigger will perform.
I'm a little naive in understanding the logic behind the Enrollment complete trigger. Is enrollment actually complete before Setup Assistant begins? I've always assumed that enrollment completed after Setup Assistant but I have no reason to assume this other than empirical evidence while working with DEP, which we've just recently started to implement.
Thanks for any insights.
Posted on 04-10-2019 03:08 PM
@adamlalicker I ended up using your script and it works well, if triggered by the user. Do you know of a way to do it or what to add to the script to allow the gui elements to appear when they run from root?
with other commands I have been using "sudo -u $3" so the logged in user is the one the command is running for. But how is this done in this case with applescript?