Prevent OneDrive Shortcut Sync with Intune

Prevent Desktop shortcuts from syncing to OneDrive using Intune

This blog post gives you a quick walkthrough of how you can prevent OneDrive from syncing shortcuts with MEM Intune.

Bet before we get started, lets understand…

Why do we need to prevent OneDrive from syncing Shortcuts?

If you have OneDrive Known Folder Redirection enabled for your Windows 10 endpoints and there are no measures to prevent desktop shortcuts and links from syncing to OneDrive, then, if for any reason, a user needs to do a system reset, post system reset and re-provisioning, the user will be seeing duplicate icons appearing on the desktop.

Having duplicate icons on your desktop as a result of OneDrive sync? Learn how to prevent OneDrive from syncing desktop shortcuts with Intune.
Having duplicate icons on your desktop as a result of OneDrive sync? Learn how to prevent OneDrive from syncing desktop shortcuts with Intune.

This is annoying and surely not a good user experience. The reason why we need to prevent OneDrive shortcut sync.

Create Administrative Templates profile in Intune to prevent OneDrive Shortcut sync.

In the Endpoint Manager admin center

  • Navigate to Devices >> Windows >> Configuration profiles
  • Click Create Profile
Create Administrative Templates profile in Intune to prevent OneDrive from syncing shortcuts.
Create Administrative Templates profile in Intune to prevent OneDrive from syncing shortcuts.
  • Select Windows 10 and later as Platform
  • Choose Templates as Profile type
  • Select Administrative Templates
  • Click Create
Create Administrative Templates profile in Intune to prevent OneDrive from syncing shortcuts.
Create Administrative Templates profile in Intune to prevent OneDrive from syncing shortcuts.
  • Give the profile a Name
  • Enter a Description (Optional)
  • Click Next
Create Administrative Templates profile in Intune to prevent OneDrive from syncing shortcuts.
Create Administrative Templates profile in Intune to prevent OneDrive from syncing shortcuts.
  • Select OneDrive from under Computer Configuration
  • Search for Exclude
  • Select Exclude specific kinds of files from being uploaded
Create Administrative Templates profile in Intune to prevent OneDrive from syncing shortcuts.
Create Administrative Templates profile in Intune to prevent OneDrive from syncing shortcuts.
  • Select Enabled
  • Enter “*.lnk” and “*.url” in the text boxes
  • Click OK
Create Administrative Templates profile in Intune to prevent OneDrive from syncing shortcuts.
Create Administrative Templates profile in Intune to prevent OneDrive from syncing shortcuts.
  • Finish creating the profile by adding scope tags as per requirement and assigning the profile to the required group.
Create Administrative Templates profile in Intune to prevent OneDrive from syncing shortcuts.
Create Administrative Templates profile in Intune to prevent OneDrive from syncing shortcuts.

Noticed the new Filter option while making assignments.

Check my previous blog post on the same to know more about the new filters option in Intune.

How the Intune Admin Template policy to prevent OneDrive Shortcut sync works?

If the exclusion of shortcuts and links is configured along with the OneDrive Known Folder redirection, the shortcuts on Desktop are not synced to OneDrive.

If the exclusion of shortcuts and links is configured along with the OneDrive Known Folder redirection, the shortcuts on Desktop are not synced to OneDrive.
If the exclusion of shortcuts and links is configured along with the OneDrive Known Folder redirection, the shortcuts on Desktop are not synced to OneDrive.

This prevents the issue that we started with – having duplicate icons on the desktop due to OneDrive sync.

However, if the exclusion of shortcuts and links is not configured along with OneDrive Known Folder redirection policy but configured at a later stage, in such case, the exclusion settings will only work to prevent syncing the new shortcuts or links, post the profile taking effect on the endpoint.

If the exclusion of shortcuts and links is not configured along with OneDrive Known Folder redirection policy but configured at a later stage, in such case, the exclusion settings will only work to prevent syncing the new shortcuts or links.
If the exclusion of shortcuts and links is not configured along with OneDrive Known Folder redirection policy but configured at a later stage, in such case, the exclusion settings will only work to prevent syncing the new shortcuts or links.

It will not remove existing synced shortcuts or links. As such, existing synced shortcuts will continue to exist and cause the duplicate icons issue on the desktop.

You can, however, delete those existing duplicate shortcuts (the ones with Copy in the name) from OneDrive by making use of PowerShell. A very raw example would be

$dir = "$env:USERPROFILE\OneDrive - LearnIntuneWithJoy\Desktop" <#Path to OneDrive#>
Get-ChildItem -Path $dir | Where-Object Name -Like '*copy*.lnk' | ForEach-Object { Remove-Item -LiteralPath $_.Name}

Wrap Up

That was all for today. Thanks for reading!

More Information: