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
Configure Wi-Fi network
networksetup –setairportnetwork <Wi-Fi interface name> <network SSID> <password>
networksetup –setairportnetwork en0 ‘Company Wi-Fi' ‘Pass123’
networksetupis 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.
setairportnetworkcommand is used to configure the Wi-Fi network of the macOS devices.
<Wi-Fi interface name>field value is usually en0. This value can be found out by running
networksetup –listallhardwareportscommand in the Mac terminal. Search for the device name under Hardware Port: Wi-Fi.
<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.