Microsoft Lync will not Uninstall

dpalmer_autoeve
New Contributor III

I am trying to get Microsoft Lync uninstalled so that Skype for Business will be our main communication app. I have indexed the package, marked it for uninstallation and even tried using a script to uninstall but Microsoft Lync refuses to go away. Here is the script I tried in conjunction with the policy I created. I have since removed the script. What is the best way to remove a packaged pushed by Casper Remote or a policy? I am missing something?

!/bin/sh

!/bin/bash

loggedInUser=/bin/ls -l /dev/console | /usr/bin/awk '{ print $3 }'

rm -rf /Applications/Microsoft Lync.app
rm -rf /Users/$loggedInUser/Library/Application Support/Microsoft Lync
rm -rf /Users/$loggedInUser/Library/Logs/Microsoft Lync-*

exit 0

13232a7091c84290a811efbe0fbae6fe
6a8f0ff051f745bbaec2b4688d012a38

1 ACCEPTED SOLUTION

rqomsiya
Contributor III

You're missing the "#" in the shebang. Use this script. Test before you run it...

#!/bin/bash

LYNC_PID=$(ps ax | grep "/Applications/Microsoft Lync.app/Contents/MacOS/Microsoft Lync" | grep -v grep | awk '{ print $1 }')
kill -9 ${LYNC_PID} 2>/dev/null

USER_LIST=`dscl . list /Users UniqueID | awk '$2 > 500 { print $1 }'`
for USER in ${USER_LIST};
do
rm -rf "/Users/$USER/Library/Preferences/com.microsoft.Lync.plist" 2>/dev/null
rm -rf "/Users/$USER/Library/Preferences/ByHost"/MicrosoftLyncRegistrationDB.*.plist 2>/dev/null
rm -rf "/Users/$USER/Library/Logs"/Microsoft-Lync*.log* 2>/dev/null
rm -rf "/Users/$USER/Documents/Microsoft User Data/Microsoft Lync Data" 2>/dev/null
rm -rf "/Users/$USER/Documents/Microsoft User Data/Microsoft Lync History" 2>/dev/null
rm -rf "/Users/$USER/Library/Keychains/"OC* 2>/dev/null
done

rm -R "/Applications/Microsoft Lync.app" 2>/dev/null
rm -R "/Library/Internet Plug-Ins/MeetingJoinPlugin.plugin" 2>/dev/null

exit 0

View solution in original post

5 REPLIES 5

rqomsiya
Contributor III

You're missing the "#" in the shebang. Use this script. Test before you run it...

#!/bin/bash

LYNC_PID=$(ps ax | grep "/Applications/Microsoft Lync.app/Contents/MacOS/Microsoft Lync" | grep -v grep | awk '{ print $1 }')
kill -9 ${LYNC_PID} 2>/dev/null

USER_LIST=`dscl . list /Users UniqueID | awk '$2 > 500 { print $1 }'`
for USER in ${USER_LIST};
do
rm -rf "/Users/$USER/Library/Preferences/com.microsoft.Lync.plist" 2>/dev/null
rm -rf "/Users/$USER/Library/Preferences/ByHost"/MicrosoftLyncRegistrationDB.*.plist 2>/dev/null
rm -rf "/Users/$USER/Library/Logs"/Microsoft-Lync*.log* 2>/dev/null
rm -rf "/Users/$USER/Documents/Microsoft User Data/Microsoft Lync Data" 2>/dev/null
rm -rf "/Users/$USER/Documents/Microsoft User Data/Microsoft Lync History" 2>/dev/null
rm -rf "/Users/$USER/Library/Keychains/"OC* 2>/dev/null
done

rm -R "/Applications/Microsoft Lync.app" 2>/dev/null
rm -R "/Library/Internet Plug-Ins/MeetingJoinPlugin.plugin" 2>/dev/null

exit 0

mm2270
Legendary Contributor III

The # wasn't likely missing from the script. It just needed to be wrapped in the script tags or the boards here interpret it as a header styling. However, pick one shebang! You have two in your script, /bin/sh and /bin/bash. You only need one.

The loop over all accounts that @rqomsiya shows above is what you should use since you can't be sure that only the logged in user has Lync related files in it when the script runs. Best to search and destroy across all accounts, just to be sure you're getting all of it.

Also, you should be aware that while indexing packages and using the uninstall functions is nice, it doesn't always work the way you might expect. Sometimes it leaves stuff behind that a script would catch. Personally I would do it via script.

dpalmer_autoeve
New Contributor III

Thank you for the input, I will try it on a test system in a few minutes. Once again thank you!

dpalmer_autoeve
New Contributor III

@rqomsiya, that script worked like a charm. Thank you, you just saved my day. @mm2270, thank you for your input.

rqomsiya
Contributor III

Glad it worked out! Mark as solved if you can so others can search this post :)