ML
    • Recent
    • Categories
    • Tags
    • Popular
    • Users
    • Groups
    • Register
    • Login

    Naming your Apple computer via the CLI

    Scheduled Pinned Locked Moved IT Discussion
    osxcliadministrationappledeployment
    2 Posts 1 Posters 583 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • DustinB3403D
      DustinB3403
      last edited by DustinB3403

      In an ongoing attempt to improve my OSX setup scripts I'm wanting to set the local computername, expected username and the asset tag.

      With the OSX cli I can use the scutil --set HostName & ComputerName & LocalHostName each from individual variables that are prompted for during execution.

      So for example

      read -p 'Enter a username: ' compuser sets that variable to be called in scutil --set ComputerName $compuser

      The reason for using the username for the computer name is because we name our computers based on the office, SAMAccountname (Username) and the asset tag.

      What I'm wanting to do is concatenate a few of these variables to set these so they match a nice unique format that makes it easier for binding to the domain later.

      This is how that script looks and works.

      #!/bin/sh
      
      # Setting the (office) offname variable
      
      read -p 'What office are you in?: ' offname
      
      # Setting computer user variable
      
      read -p 'Enter the computer username ie jdoe: ' compuser
      
      # Setting asset tag variable
      
      read -p 'Enter this computers asset tag: ' tagnumber
      
      scutil --set HostName $offname$compuser && scutil --set ComputerName $compuser$tagnumber && scutil --set LocalHostName %offname$compuser$tagnumber
      
      1 Reply Last reply Reply Quote 2
      • DustinB3403D
        DustinB3403
        last edited by DustinB3403

        I've added this to a larger script that I use, but if you only wanted to automate the naming process the above would work for you.

        Else just remove the header #!/bin/sh and add the reset to any setup scripts that you have to automate this portion of the setup.

        1 Reply Last reply Reply Quote 0
        • 1 / 1
        • First post
          Last post