Hello.  I've been playing with scripting for Pre-Installation task, but I really don't know shell scripting or applescript very well.  The whole process would consist of both a Pre-Installation and a Post-Installation task.  The Pre-Install task would use just simply ask "What will be the name of this Mac?"  Something that I've been able to accomplish with the applescript: display dialog "What will be the name of this Mac?" default answer ""  Then the answer would be saved and during the Post-Install task, it just assigns the computer name to the Mac after imaging.

Pretty simple.  Can anyone help?
2 Comments   [ + ] Show Comments


  • Just to clarify, I have a pre-install script that works perfectly: Asking the name of the Mac and writing that text to a file on the Kace desktop (or wherever I want to put it). What I need is the post-install script that extracts the text from that file and sets the computer name based on that extracted text. As a bonus, it would be nice to have it allow spaces for the ComputerName and automatically add dashes for the HostName and LocalHostName as well. But I would be happy with all three being the same, no spaces.
  • To further clarify: here is my script:

    tell application "Finder"
    mount volume "smb://usr:pass@server/share"
    display dialog "What will be the name of this Mac?" default answer ""
    set MacOSXComputerName to text returned of result
    set SerialNumber to do shell script "/usr/sbin/system_profiler SPHardwareDataType | awk '/Serial/ { print $NF }' "
    set textfile to "/Volumes/kace/mac software/_MacImageNames/" & SerialNumber & ".txt"
    do shell script "echo " & quoted form of MacOSXComputerName & " > " & quoted form of textfile
    end tell

    Now, I really need some help getting the backend script that can identify the serial number of the unit so it knows which txt file to pull from and then use "scutil --set ComputerName" to write the name.
Please log in to comment


you can probably just use the top part of this as a post script.  I found this via google and they are testing using this on new macs to name and join to the domain.

Answered 06/30/2014 by: SMal.tmcc
Red Belt

  • Thank you for helping. Sadly, that script does not seem to accomplish the task I'm looking for. I tried it out, but it still never asks for the computer name. Also, what I really need is a pre-install task that asks for the computer name right away, saves it and applies it after imaging is complete.
    • here are a couple of links that talk about asking from the name.
      • Thank you, I'd previously seen both of those sites in my searching and it's just not working out.
Please log in to comment
Answer this question or Comment on this question for clarity