Script to remove Lync 2011 & Skype for Business Mac Beta

marc_grubb
New Contributor III

If you are about to deploy Skype for Business Mac, you will first need to remove Lync 2011 and Skype for Business Mac Beta.

This is a script to remove all items listed on How to perform a clean uninstall of Lync for Mac 2011. In addition, it will remove the corresponding Skype for Business Mac Beta files. The script removes Apps, caches, cookies, Keychain entries, preferences, receipts and logs. (But not Dock items). There is a similar, more mature script with feedback posted on jamf Nation here, though it's not as thorough.

I've tested this script in my AD environment.

Feel free to improve upon this.

#!/bin/sh
# script to remove items listed on https://support.microsoft.com/en-us/kb/2691870 "How to perform a clean uninstall of Lync for Mac 2011"
# 10/25/2016-added lines based on script Dave Fisher posted on Slack
# 10/25/2016-Lucas Vance from jamf support helped with cut commands for userEmail
# tested in an AD environment

# Pull current logged in user into 'user' variable.
user=`ls -l /dev/console | cut -d " " -f 4`

# #2 Kill Lync & SfB
killall "Microsoft Lync"
killall "Skype for Business"

# #3 Delete the Lync & SfB applications
rm -rf /Applications/Microsoft Lync.app
rm -rf /Applications/Skype For Business.app

# #4 Delete caches, cookies, OC_KeyContainer, preferences, receipts & logs (if present) 
rm -rf /Users/$user/Library/Application Support/com.apple.sharedfilelist/com.apple.LSSharedFileList.ApplicationRecentDocuments/com.microsoft.lync.sfl
rm -rf /Users/$user/Library/Cookies/com.microsoft.Lync.binarycookies
rm -rf /Users/$user/Library/Caches/com.microsoft.Lync
rm -rf /Users/$user/Library/Group Containers/UBF8T346G9.Office/Lync
rm -rf /Users/$user/Library/Logs/Microsoft-Lync*
rm -rf /Users/$user/Library/Preferences/ByHost/MicrosoftLync*
rm -rf /Users/$user/Library/Preferences/com.microsoft.Lync.plist
rm -rf /Users/$user/Library/Receipts/Lync.Client.Plugin.plist
rm -rf /Users/$user/Library/Keychains/OC_KeyContainer*

rm -rf /Users/$user/Library/Preferences/com.microsoft.SkypeForBusinessTAP.plist
rm -rf /Users/$user/Library/Logs/com.microsoft.SkypeForBusinessTAP
rm -rf /Users/$user/Library/Application Support/Skype for Business
rm -rf /Users/$user/Library/Application Support/com.apple.sharedfilelist/com.apple.LSSharedFileList.ApplicationRecentDocuments/com.microsoft.skypeforbusinesstap.sfl
rm -rf /Users/$user/Library/Application Support/com.microsoft.SkypeForBusinessTAP
rm -rf /Users/$user/Library/Cookies/com.microsoft.SkypeForBusinessTAP.binarycookies

# #5 Delete Lync & Skype User Data (but keep Lync Conversation History)
rm -rf /Users/$user/Documents/Microsoft User Data/Microsoft Lync Data 
rm -rf /Users/$user/Documents/Microsoft User Data/Microsoft/Communicator

# #6 remove this file from the Keychains folder and therefore, the Keychain
rm /Users/$user/Library/Keychains/OC_KeyContainer*

# #7 Delete the following KeyChain entry using security command
# $user variable is still in place from earlier

# Pull current logged in user's e-mail address into 'userEmail' variable.
userEmail=$(dscl . -read /Users/$user EMailAddress | cut -f2 -d":" | cut -f2 -d" ")
security delete-certificate -c $userEmail /Users/$user/Library/Keychains/login.keychain
security delete-generic-password -l "OC_KeyContainer*" /Users/$user/Library/Keychains/login.keychain
8 REPLIES 8

maxbehr
Contributor II

@marc_grubb thanks for this…any idea when we might actually see the release of Skype for Business on the Mac?

maxbehr
Contributor II

oops see that it was just announced.

khey
Contributor
rm -rf /Users/$user/Library/Preferences/com.microsoft.SkypeForBusinessTAP.plis

just missing t at the end there.

does anyone know where is the user's plist file for Skype for Business?

rseward
New Contributor

These two files seem to be involved.

If you click 'Delete Sign-In Info' at the login screen this is the only file that seems to be modified.
~/Library/Containers/com.microsoft.SkypeForBusiness/Data/Library/Application Support/Skype for Business/offlinestorageNormal.dat

However the 'Enter your Email Address' and 'Enter your User Name' fields still remember the user details, until you rename/delete this.
~/Library/Containers/com.microsoft.SkypeForBusiness/Data/Library/Application Support/com.microsoft.SkypeForBusiness/DataStore.sqlite

wmateo
Contributor

@marc_grubb Thanks for this. are you automatically logging in your users? I used to have a script that automatically logged in my users, but now with the new SFB doesn't seem to work.

mrbill
New Contributor II

I get an error when running the script:

rm: /Users/<username>/Library/Keychains/OC_KeyContainer*: No such file or directory
security: SecKeychainSearchCopyNext: The specified item could not be found in the keychain.

The OC_KeyContainer file is there, but it also contains the email address. OC_KeyContainer_username@domain.com. I'm assuming the wild card should get this?

Not sure about the security error.

Any thoughts?

marc_grubb
New Contributor III

@khey Thanks for catching that typo. I corrected it.
@mrbill I see that error too. As far as I can tell, it's benign and the remainder of the script works correctly.

kenbutcher
New Contributor

Hi, Thanks for posting this script, it works to a point, but I am struggling with the last part, security delete-generic-password -l "OC_KeyContainer*" /Users/$user/Library/Keychains/login.keychain - the wildcard is not picking up the keychain object.
If i put the full name it finds it and removes it. Any ideas on how to get this working?

Thanks for any replies :)