Last active
March 3, 2017 05:36
-
-
Save bryanzak/9065400 to your computer and use it in GitHub Desktop.
ARD Admin 3.7.1 Fixer - a script to cause ARD Admin to effectively "forget" all cached IP and DNS information for known computers. This deals with a problem in ARD Admin 3.7.1 where it seems to be too aggressive in caching this information
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 | |
SCRIPT_VERSION="1.0" | |
# some background info here: https://discussions.apple.com/message/24596710#24596710 | |
# 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/Preferences" | |
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" == "1" ]]; then | |
echo "Remote Desktop Admin 3.7.1 installed, proceeding to fix...." | |
else | |
echo "### ERROR: Remote Desktop Admin $version installed. Requires 3.7.1..." | |
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 |
@cjduckk I assume it picks them up from the scanner, I did this and reloaded my scanners by subnet and had 1100 macs updated almost immediately.
p.s. thanks for the script, ARD 3.7.1 had become unusable for me, this definitely helps.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Since this script clears the "DNS Name" attribute for every machine in the All Computers list, how do you go about repopulating this field? I'm sure with the size of your network, doing it manually for every machine would not be reasonable.