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
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.
Thank you for the input, I will try it on a test system in a few minutes. Once again thank you!
@rqomsiya, that script worked like a charm. Thank you, you just saved my day. @mm2270, thank you for your input.
Glad it worked out! Mark as solved if you can so others can search this post