Populating Favorite Servers list

wmateo
Contributor

I was wondering if anyone has found a quick, efficient way to do populate the favoriteservers in com.apple.sidebarlists.plist - I tried uploading plist to config profile, and configuring, all MCX to no avail. I saw a few scripts, but they didn't seem to work or were overkill for what I needed and they were really old. Does anyone have this working in their environment with minimal effort, and easy to update? would you mind sharing?

I was able to accomplish this packaging the plist and using FEU/FUT and deploying it as a policy, and adding to self service. After a restart, it worked fine. we didn't care what the user had in this list and we straight overwrote, and deploy with the once per computer trigger, allowing user to add. I know there is away using the defaults command, but could not get the syntax corrrect...

any input will be appreciated.

3 REPLIES 3

esantiago
New Contributor

+1 - Need help with this too.

jacob_salmela
Contributor II

Here is my solution on Github.

#!/bin/bash
bud='/usr/libexec/Plistbuddy'
plist=$HOME'/Library/Preferences/com.apple.sidebarlists.plist'

servers=('afp://servername'
'smb://servername'
'vnc://servername'
'ftp://servername')

killall cfprefsd
echo "Setting servers for $plist"
echo "Removing previous entries..."
${bud} -c "Delete favoriteservers" ${plist}

echo "Creating new list..."
${bud} -c "Add favoriteservers:Controller string CustomListItems" ${plist}
${bud} -c "Add favoriteservers:CustomListItems array" ${plist}

for i in "${!servers[@]}"
do
    echo "Adding to Favorite Servers: ${servers[$i]}..."
    ${bud} -c "Add favoriteservers:CustomListItems:$i:Name string ${servers[$i]}" ${plist}
    ${bud} -c "Add favoriteservers:CustomListItems:$i:URL string ${servers[$i]}" ${plist}
done

echo "Finalizing settings..."
killall cfprefsd
defaults read ${plist} favoriteservers > /dev/null

esantiago
New Contributor

Thanks - I'll try this.