Skip to main content
Question

Adding a Wireless Profile using a script

  • September 10, 2018
  • 0 replies
  • 0 views

Forum|alt.badge.img+1

We have a Wireless Profile in the Enterprise which i need to automate to push it out to all the systems in the environment.
I already have a script which after installing the .config profile, installs the certs and grant it 'Trust Access' in the key chain.
It also add the profile in the W-Fi 'advanced Settings with the following parameters.

Network Name - abcd
Security - WPA/WPA2 enterprise
Mode - EAP-TLS
Identity - Ad Certificate.
The issue is here in selecting the correct certificate in 'Identity'. Currently what the script is doing is it is selecting the 1st option from the Drop-Down , where as i want to select the last option from the 'Identity' Drop-Down which i am unable to do.

Here is my Script. Any help/Suggestion to select the last option from the drop-down will be really helpful.

sudo security add-trusted-cert -d -r trustAsRoot -k /Library/Keychains/System.keychain /Library/Certificate/certs.mobileconfig

Cert="$compname.xxx.xxx.com" security set-identity-preference -c "$Cert" -s "com.apple.network.eap.user.identity.wlan.ssid.3apt1s" /Library/Keychains/System.keychain wservice=/usr/sbin/networksetup -listallnetworkservices | grep -Ei '(Wi-Fi|AirPort)' wirelessnw=networksetup -getairportnetwork $hwports | cut -d " " -f 4 # Grab the names of the adapters. We assume here that any ethernet connection name ends in "Ethernet" eth_names=networksetup -listnetworkserviceorder | sed -En 's|^(Hardware Port: .*LAN, Device: (en.))$|1|p' air_name=networksetup -listnetworkserviceorder | sed -En 's/^(Hardware Port: (Wi-Fi|AirPort), Device: (en.))$/2/p' # Set Wifi On

/usr/sbin/networksetup -setairportpower $air_name on sleep 10 if [[ $wirelessnw == "abcd" ]]; then echo "Connected to abcd" else echo "Machine is not connected to abcd. Checking identity preference" security get-identity-preference -s "com.apple.network.eap.user.identity.wlan.ssid.abcd" /Library/Keychains/System.keychain fi
sudo rm -rf /Library/Certificate

0 replies

Be the first to reply!

Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings