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
Configure Wi-Fi network
1 2 |
#!/bin/bash networksetup –setairportnetwork <Wi-Fi interface name> <network SSID> <password> |
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 runningnetworksetup –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.