Created
May 4, 2018 03:09
-
-
Save iamshreeram/85f3596e3b48629ba07054c04029109f to your computer and use it in GitHub Desktop.
Shell scripts for removing preferred wireless network
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Source is from mbreeden/network of github | |
| if [ "$(/usr/sbin/networksetup -getairportnetwork en0)"="Current Wi-Fi Network: Faculty_Access" ]; then | |
| /usr/sbin/networksetup -removepreferredwirelessnetwork en0 "Faculty_Access" | |
| /usr/sbin/networksetup -setairportpower en0 off | |
| /usr/sbin/networksetup -setairportpower en0 on | |
| /usr/bin/security delete-generic-password -a "Faculty_Access" /Library/Keychains/System.keychain | |
| user=$(ls /Users | grep -v ".localized" | grep -v "Shared"| grep -v "Guest" | grep -v ".DS_Store" | grep -v "admin") | |
| keychain=$(ls /Users/$user/Library/Keychains | grep -v "login.keychain-db" | grep -v ".f" | grep -v "metadata.keychain-db") | |
| /bin/rm -rf /Users/$user/Library/Keychains/$keychain | |
| else | |
| echo "Not Connected to Faculty_Access" | |
| fi | |
| exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment