Why want you to create desktop shortcuts with Intune? Business specific apps may require special shortcuts in order to launch the application with the right parameters. Or you need to create a shortcut for an application which is stored on your on premises fileserver. For this purpose I created a little solution which closes the gap between the modern cloud and on premises world. In comparison with other solutions this one works if you have redirected the users desktop with OneDrive Known Folder Move and automatically remediates missing shortcuts if they got deleted.

Direct link to the GitHub repository.

Browser links: Instead of placing shortcuts to websites on the desktop I would recommend you to use managed bookmarks which can be directly provisioned within the web browser. I documented this for the new Microsoft Edge based on chromium here. {: .notice}

Features

  • This solution works when the desktop is redirected with OneDrive Known Folder Move
  • Everything is user based (local userprofile)
  • If the shortcut is missing or deleted it gets automatically (re)created
  • Possibility to remove shortcut via Intune Win32 app uninstall
  • Shortcut can point to: URL, File (UNC) or Folder (UNC)
  • Ability to pass shortcut arguments
  • Ability to specify shortcut icon (UNC/URL)
  • Ability to deploy shortcut together with an app using Intune Win32 app dependencies

Architecture

A simple PowerShell script which does all the shortcut stuff is wrapped as Intune Win32 App. This adds possibility to detect the presence of the shortcut and if required to uninstall it with Intune. In order to work with the redirected desktop to OneDrive with Known Folder Move we can take advantage of the [Environment]::GetFolderPath("Desktop") method to resolve the desktop location. Based on the Win32 app configuration the shortut get’s either created on the users personal desktop or on the allusers desktop.

Configuration

You can find a prepackaged Intune Win32 app file of the “CreateDesktopIcon.ps1” script on my GitHub repository available for download. You can also wrap the scripts by yourself by using the IntuneWinAppUtil.exe available as download here.

Available parameters

The PowerShell script supports the following command line parameters:

ParameterExplanation
-ShortcutTargetPathTarget path for your shortcut (URL, UNC) (file/folder)
-ShortcutDisplayNameDisplay name without file ending
[-PinToStart]Optional: Create start additional start menu shortcut
[-IconFile]Optional: Custom icon file for the shortcut (URL, UNC)
[-ShortcutArguments]Optional: Additional command line arguments for the shortcut
[-WorkingDirectory]Optional: WorkingDirectory for the shortcut

Intune Win32 app configuration

Create a shortcut on the users personal desktop

To create a shortcut on the user’s personal desktop I will show you an example for a “cmd” shortcut.

Create a new Win32 app in Intune and upload the “CreateDesktopIcon.intunewin” you downloaded from my GitHub repository or wrapped by yourself.

Configure the program settings and specify the parameters for the shortcut creation depending on your needs.

SettingValue
Install command%windir%\sysnative\windowspowershell\v1.0\powershell.exe -ExecutionPolicy Bypass -file "CreateDesktopIcon.ps1" -ShortcutTargetPath "cmd" -ShortcutDisplayName "cmd"
Uninstall command%windir%\sysnative\windowspowershell\v1.0\powershell.exe -ExecutionPolicy Bypass -file "RemoveDesktopIcon.ps1" -ShortcutDisplayName "cmd"
Install behaviorUser

We call Powershell from the sysnative path otherwise we only have a PowerShell x86 environment which doesn’t get along with environment variables. Make also sure to change the Install behavior to User because the Intune management extension needs to be in the user context to access ones users personal desktop. {: .notice–warning}

And the detection settings:

SettingValue
Rules formatUse a custom detection script
Script fileUse this detection script

Make sure to change the $shortcutName variable in the detection script to match your shortcut display name (without file ending). {: .notice–warning}

Here’s a little gif which covers the Intune part step by step: Intune add desktop shortcut to user’s desktop

Create a shortcut on the allusers desktop

To create a shortcut on the allusers desktop I will show you the example for the cmd app. It’s basically the same set-up for the application part as for the user’s desktop shortcut except that we can leverage on Intune’s built-in detection rules to detect the shortcut on the allusers (public) desktop.

SettingValue
Install command%windir%\sysnative\windowspowershell\v1.0\powershell.exe -ExecutionPolicy Bypass -file "CreateDesktopIcon.ps1" -ShortcutTargetPath "cmd" -ShortcutDisplayName "cmd"
Uninstall command%windir%\sysnative\windowspowershell\v1.0\powershell.exe -ExecutionPolicy Bypass -file "RemoveDesktopIcon.ps1" -ShortcutDisplayName "cmd"
Install behaviorSystem

And the detection settings:

SettingValue
Rules formatManually configure detection rules
Detection rulesFile or folder exists “%PUBLIC%\Desktop\cmd.lnk”

Examples

Open a website with a specific browser

To create a shortcut which opens a website with a specific browser select the browser as target and pass the URL for the website as argument:

1
& "CreateDesktopIcon.ps1" -ShortcutTargetPath "%ProgramFiles(x86)%\Microsoft\Edge\Application\msedge.exe" -ShortcutDisplayName "nicolonsky tech" -IconFile "https://tech.nicolonsky.ch/favicon.ico" -ShortcutArguments "https://tech.nicolonsky.ch"

Shortcut for Windows Store apps

To create shortcuts for Windows Store apps (universal apps) you will need the “Application User Model ID” (AUMID). This one can easily be retrieved with PowerShell by running Get-StartApps then just copy and adjust the AppID. Here’s an example for the Intune company portal:

1
& "CreateDesktopIcon.ps1" -ShortcutTargetPath "shell:AppsFolder\Microsoft.CompanyPortal_8wekyb3d8bbwe!App" -ShortcutDisplayName "Company Portal"

And here another one for the new Windows Terminal:

1
& "CreateDesktopIcon.ps1" -ShortcutTargetPath "shell:AppsFolder\Microsoft.WindowsTerminal_8wekyb3d8bbwe!App" -ShortcutDisplayName "Terminal"

Hint shortcuts for Windows Store apps can only be created on the users desktop as the apps are individually installed per user. Find more details about gathering the AUMID in this Microsoft Docs article. {: .notice–warning}

Shortcut to OneDrive folder

To point to the users OneDrive folder we can use the built in PowerShell environment variable $env:OneDriveCommercial which points to his Office 365 OneDrive folder in explorer:

1
& "CreateDesktopIcon.ps1" -ShortcutTargetPath "$env:OneDriveCommercial" -ShortcutDisplayName "OneDrive"

Shortcut with default Windows Shell Icons

If you want to use icons which ship with Windows you can use the -IconFile parameter and use %SystemRoot%\System32\SHELL32.dll,27 as path. The number after the comma represents the icon index. A list with all numbers and icons is available here.

Example for a shutdown shortcut with a shutdown icon:

1
& "CreateDesktopIcon.ps1" -ShortcutTargetPath "shutdown" -ShortcutDisplayName "shutdown" -ShortcutArguments "-s -t 60" -IconFile "%SystemRoot%\System32\SHELL32.dll,27"

Happy Desktop-Shortcuting.