Last active
August 23, 2018 04:46
-
-
Save AndrewWCarson/6ad5574e52adcfb31aa729da4670f3d4 to your computer and use it in GitHub Desktop.
Add Favorite Servers in macOS
This file contains 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 | |
# (C) Andrew Worth Carson | |
# MIT License: https://andrewworthcarson.com/mit_license.html | |
declare -a servers=('smb://server/share' 'smb://anotherserver/anothershare') | |
range=$(seq 0 1 $(expr ${#servers[@]} - 1)) | |
for user in $(dscl . list /Users UniqueID | awk '$2 >= 500 {print $1}'); do | |
# Add each server to favorites | |
for index in $range; do | |
sudo -u "${user}" sfltool add-item -n "${servers[$index]}" com.apple.LSSharedFileList.FavoriteServers "${servers[$index]}" | |
done | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Improved user iteration significantly.