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.
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.
- 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
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.
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.
The PowerShell script supports the following command line parameters:
|-ShortcutTargetPath||Target path for your shortcut (URL, UNC) (file/folder)|
|-ShortcutDisplayName||Display 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.
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.
And the detection settings:
|Rules format||Use a custom detection script|
|Script file||Use this detection script|
Make sure to change the
$shortcutName variable in the detection script to match your shortcut display name (without file ending).
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.
And the detection settings:
|Rules format||Manually configure detection rules|
|Detection rules||File or folder exists “%PUBLIC%\Desktop\cmd.lnk”|
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:
& "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:
& "CreateDesktopIcon.ps1" -ShortcutTargetPath "shell:AppsFolder\Microsoft.CompanyPortal_8wekyb3d8bbwe!App" -ShortcutDisplayName "Company Portal"
And here another one for the new Windows Terminal:
& "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.
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:
& "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:
& "CreateDesktopIcon.ps1" -ShortcutTargetPath "shutdown" -ShortcutDisplayName "shutdown" -ShortcutArguments "-s -t 60" -IconFile "%SystemRoot%\System32\SHELL32.dll,27"