Mac Deployment One Click Script

We don't have Casper in our environment, so everything is still quite manual when deploying a mac. One day I was so tired of endless click to join a mac to AD. then I start working on mac deployment.

The main script for macs to join AD is from Vaughn Miller,

For my script, you can download from here:

What does this one click script do:

  1. Run as root (if not, will prompt you to do so) (Q);
  2. Ask you for computer name, username, and password to join AD (;
  3. Enable mobile account (;
  4. Add domain groups to local admin group (;
  5. Install Mac SCCM client (Q);
  6. Install ESET Anti-virus software  (Q);
  7. Ask for reboot (Q)

Some Q & A

  • What is the file Q?
    Q is an Unix Executable File, there's no file extension for it, but when you double click, it will run.
  • How to create Unix Executable File on Mac?
    Open your terminal and type, chmod +x file_name
  • What does path=$( cd “$( dirname “${BASH_SOURCE[0]}” )” && pwd ) mean?
    Find the absolute path of the current script is running location. You may think path = pwd should work, but it didn't.
    I also tried using path = ‘dirname $0', not working neither
  • When running a shell script inside an unix executable file, can I just use sudo sh path/
    I tried and it failed. because if there are some spaces in the path, it will said file does not exist. using ${path} can include the spaces inside the path.
  • What if there are some spaces in my network admin group? For example, “AD\* Admin HD”?
    In this case, we need to use AD\\*\ Admin\ HD ( add “\” before the space, and if there is an actual “\”, use double “\\”. and if you have more than one admin group needs to add, use “,” to combine.


Leave a Comment