Delete Desktop Shortcuts using Intune

You can easily create desktop shortcuts using Intune on Windows 10/11 devices at Public desktop location or User’s profile desktop location. A standard users may not have the permissions to delete desktop shortcuts from C:\Users\Public\Desktop location, but have the permission to delete desktop shortcuts from user’s profile folder.

In this blog post, we will demonstrate how to delete desktop shortcuts of applications, including web lists shortcuts, using Intune and PowerShell scripts from below two locations.

  • Public desktop location (C:\users\public\desktop).
  • Users profile desktop location (C:\users\<username>\desktop) or C:\Users\<username>\OneDrive – <org>\Desktop, if Windows known folders are redirected to OneDrive.

Prepare the PowerShell Scripts

I have created three PowerShell scripts for deleting desktop shortcuts via Intune. You can click on below link to download script files from my GitHub repo and use it to delete desktop shortcuts.

Important Points About the Script

  • Script can delete a single or multiple desktop shortcuts, depending upon the input in the $ShortcutFiles variable.
  • If you delete desktop shortcuts from C:\users\public\desktop location, it will be removed from the desktop of all users who use the device.
  • You only need to update $ShortcutFiles to provide the list of shortcuts you want to delete. You can also include web link shortcuts or any other files you want to remove from desktop. For example: $env:Public\Desktop\dailylog.txt or $env:Public\Desktop\webapp.html.
$ShortcutFiles = @(
    "$env:Public\Desktop\chrome.lnk",
    "$env:Public\Desktop\bitwarden.lnk",
    "$env:Public\Desktop\filezilla.lnk"
)

Deploy PowerShell Script to Delete Desktop Shortcuts

  • Sign in to the Intune admin center > Devices Scripts and remediations > Platform Scripts.
  • Click on + Add and then Select Windows 10 and later.
  • Basics: Provide a Name and Description of the deployment.
  • Script settings: Browse and select the script file. For deleting desktop shortcuts from Public desktop location, select Delete_Desktop_Shortcuts_Public.ps1 script file and configure script settings as shown in below screenshot:
Delete desktop shortcuts from Public Desktop location via Intune
  • If you want to delete desktop shortcuts from user’s profile desktop location (C:\users\<username>\desktop or C:\Users\<username>\OneDrive – <org>\Desktop) then you can browse to Delete_Desktop_Shortcuts_UsersProfile.ps1 script file and configure script settings as shown in below screenshot:
Delete desktop shortcuts from Users Profile Desktop location via Intune
  • Assignments – Click on Add Groups and add an Entra security group containing Windows devices.
  • Review + add – Review the information and click Add to start the deployment process.

Monitor PowerShell Script Deployment

To verify the status of PowerShell script execution from the Intune admin center, follow the below steps:

  • Sign in to the Intune admin center > Devices Scripts and remediations > Platform Scripts. Click on the Script deployment and go to the Overview page to find the status.

For other ways to check and confirm the status of a PowerShell script, you can refer to the section #Verify PowerShell Script Execution Status of the blog post, How to deploy a PowerShell script using Intune.

Sync Intune Policies

The device check-in process might not begin immediately. If you’re testing this policy on a test device, you can manually kickstart the Intune sync either from the device itself or remotely through the Intune admin center.

Alternatively, you can use PowerShell to force the Intune sync on Windows devices. Another way to trigger the Intune device check-in process is by restarting the device.

End User Experience

After you create PowerShell script deployment on Intune, desktop shortcuts will be deleted from either Public desktop location or User’s profile desktop location, depending upon the PowerShell script used.

Verification of Deletion of desktop shortcut via Intune

Conclusion

In this blog post, we’ve discussed the process of deleting desktop shortcuts from C:\Users\Public\Desktop location, and from C:\Users\<username>\Desktop or C:\Users\<username>\OneDrive – myorg\Desktop location.

The steps provided in this blog post are not limited to just deleting desktop shortcuts. You can customize the script to target any file location and type. For example, if you want to remove a file, such as C:\Temp\testfile.txt or D:\Human Resources\dailylog.xlsx, you can easily customize the PowerShell script to target these files.

Read Next

Leave a Comment