This is exactly what I am using...
#!/bin/bash
SCRIPT_VERSION="1.0"
# some background info here: https://discussions.apple.com/thread/5520097?answerId=24596710022#24596710022
# verify ARD Admin version
# quit ARD Admin - if running, wait 10 seconds
# kill cfprefsd
# rename plist
# sed
plist_path="$HOME/Library/Containers/com.apple.RemoteDesktop/Data/Library/Prefer ences"
plist_name="com.apple.RemoteDesktop.plist"
plist_backup="com.apple.RemoteDesktop-backup.plist"
VerfiyARDAdmin()
{
if [ -d "/Applications/Remote Desktop.app" ]; then
version=$(defaults read "/Applications/Remote Desktop.app/Contents/Info" CFBundleVersion)
major_version=$(echo "$version" | cut -d. -f1)
minor_version=$(echo "$version" | cut -d. -f2)
bugfix_version=$(echo "$version" | cut -d. -f3)
if [[ "$major_version" == "3" ]] && [[ "$minor_version" == "7" ]] && [[ "$bugfix_version" == "2" ]]; then
echo "Remote Desktop Admin 3.7.2 installed, proceeding to fix...."
else
echo "### ERROR: Remote Desktop Admin $version installed. Requires 3.7.2..."
exit 1
fi
else
echo "### ERROR: Remote Desktop Admin not installed"
exit 1
fi
}
QuitARD()
{
app="Remote Desktop"
ignore=$(ps -A | egrep -i "$app" | grep -v grep)
isopen=$?
if [ $isopen != 1 ]; then
{
echo "Quitting Remote Desktop..."
osascript -e "tell application \"Remote Desktop\"" -e 'quit' -e 'end tell'
sleep 15 # give cfprefsd enough time to flush the the preferences
}
fi
}
QuitCFPrefsDaemon()
{
echo "Quitting CFPrefs Caching Daemon..."
killall cfprefsd
}
ProcessPList()
{
echo "Backing up Remote Desktop plist..."
cd "$plist_path"
mv -f "$plist_path/$plist_name" "$plist_path/$plist_backup"
echo "Converting plist to XML...."
plutil -convert xml1 "$plist_path/$plist_backup"
echo "Editing Remote Desktop plist..."
pattern1="<key>hostname<\/key>/<key>blah_1<\/key>"
pattern2="<key>hostnames<\/key>/<key>blah_2<\/key>"
pattern3="<key>networkAddress<\/key>/<key>blah_3<\/key>"
pattern4="<key>networkAddresses<\/key>/<key>blah_4<\/key>"
pattern5="<key>primaryIdentfier<\/key>/<key>blah_5<\/key>"
sed "s/$pattern1/g;s/$pattern2/g;s/$pattern3/g;s/$pattern4/g;s/$pattern5/g" "$plist_path/$plist_backup" > "$plist_path/$plist_name"
echo "Converting plist to binary...."
plutil -convert binary1 "$plist_path/$plist_name"
}
clear
VerfiyARDAdmin
QuitARD
QuitCFPrefsDaemon
ProcessPList
exit 0