Category filter

Script to configure Wi-Fi on Mac

To set up a Wi-Fi network on Mac, users have to manually configure the Wi-Fi network under System Preferences. Configuring a single device may seem effortless; however, setting up Wi-Fi for multiple devices can be a tedious process. To overcome this obstacle, you can execute custom scripts remotely on endpoints using Hexnode UEM. This enables IT admins to remotely set up Wi-Fi networks on their endpoint devices with ease.

Scripting Language – Bash

File extension – .sh


The Sample Scripts provided below are adapted from third-party Open-Source sites.

Configure Wi-Fi network

For example:
networksetup –setairportnetwork en0 ‘Company Wi-Fi' ‘Pass123’

  • networksetup is a command-line tool used to configure a client’s network settings. It includes a variety of support commands to configure various network connections and related settings.
  • The setairportnetwork command is used to configure the Wi-Fi network of the macOS devices.
  • The <Wi-Fi interface name> field value is usually en0. This value can be found out by running networksetup –listallhardwareports command in the Mac terminal. Search for the device name under Hardware Port: Wi-Fi.
  • Replace <network SSID> with the required Wi-Fi network name. This field is case-sensitive.
  • Fill the <password> field if the Wi-Fi network is password secured.
  • Running the above script will automatically connect the device with the configured Wi-Fi network.

  • In Bash script, inserting space while defining network SSID may be treated as an argument separator by the shell interpreter. Insert network SSID and password in single quotes to avoid this.
  • It is recommended to manually validate the script execution on a system before executing the action in bulk.
  • Hexnode will not be responsible for any damage/loss to the system on the behavior of the script.

  • Sample Script Repository