MEM – Removing MS Teams Desktop Shortcuts
Welcome! In today’s post, we’ll be removing the Microsoft Teams desktop shortcut, if you’ve ever deployed Office via Intune, you’ve most likely run into issues with the MS Teams desktop shortcut duplicating when OneDrive known folder move is in place and the device has been reset via Autopilot. Unfortunately, Microsoft doesn’t provide any options to prevent the creation of the shortcut, there’s plenty of UserVoice entries for it though, so cast your vote here. To work around this, we’ll be creating a Win32 application deployment that removes the desktop shortcuts on end-users profiles with a detection method to determine if the shortcuts are present.
The Issue
When MS Teams is deployed, it creates a user specific application that also deploys a desktop shortcut to the end-users desktop, OneDrive known folder move will sync the desktop shortcuts, so if a device is rebuilt or the end-user is sharing devices, duplicates occur:
The Scripts
Two scripts are needed for the win32 application, one for the installation (aka the actual command that removes the shortcuts) and the detection method to determine if the shortcuts are present.
Installation script contents
Save this script as ‘RemoveTeamsFromUsersDesktop.ps1’
$Desktop = [Environment]::GetFolderPath("Desktop")
Remove-item -path $Desktop\* -filter "Microsoft Teams*.lnk"
Detection method script contents
Save this script as ‘DetectionMethod_TeamsNOTPresentOnDesktop.ps1’
$Desktop = [Environment]::GetFolderPath("Desktop")
if (-Not (Test-Path "$Desktop\Microsoft Teams*")) {
Write-Host "Not Present"
}
Creating the Win32 app
Download the win32 wrapping tool here, extract and with the above installation ps1 script, run the tool to create your .intunewim file. Once done, create a win32 application within the MEMAC portal, then going to Apps, Windows, Add:
Select Windows app (Win32) and proceed:
Upload the .intunewim file created previously:
Set a name and desciption that suites, then on the Program section, add in the following as the install command: powershell.exe -ExecutionPolicy Bypass -command “& ‘.\RemoveTeamsFromUsersDesktop.ps1′” and uninstall as a dummy bat, in the end it should look like this:
Requirements:
Detection rules, upload the script as above, it should look like so:
Deploy the script to a test user \ user group and ensure that the Microsoft Teams desktop shortcuts have been removed.
Note
Because of how the ‘installation’ script and the detection method works, there may be a delay of up to 24 hours before the application evaluation takes place before the script is reran if a new desktop shortcut is detected.