Created
February 25, 2019 08:18
-
-
Save MelvinStans/ea1404e7c81598fe8383e7ba227c748f to your computer and use it in GitHub Desktop.
Mac network location reset
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/sh | |
########################################################################################## | |
# Create time date stamped log | |
########################################################################################## | |
logFile="/private/var/log/OurCompany.log" | |
log () { | |
/bin/echo $1 | |
/bin/echo $(date "+%Y-%m-%d %H:%M:%S: ") $1 >> $logFile | |
} | |
log "-----" | |
log "Begin script 100_resetNetworkLocationAndPorts.sh" | |
log "Adjust Network Locations to correctly add network ports" | |
sleep 5 | |
########################################################################################## | |
# Create a temporarily Network location and recreate the Automatic location. | |
########################################################################################## | |
networksetup -createlocation TempLoc populate | |
sleep 5 | |
networksetup -switchtolocation TempLoc | |
sleep 2 | |
networksetup -deletelocation Automatic | |
sleep 2 | |
networksetup -createlocation Automatic populate | |
sleep 5 | |
networksetup -switchtolocation Automatic | |
sleep 5 | |
networksetup -deletelocation TempLoc | |
log “Network Location Setup Completed.” | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment