How to create a desktop shortcut using Intune

Typically, when you install any application, it creates a desktop shortcut for convenient user access. Nonetheless, certain third-party, custom, or in-house applications may not automatically create a desktop shortcut. In such instances, you can use Intune to deploy a shortcut for the application.

You have below two locations where you can deploy a desktop shortcut:

  1. At “AllUsersDesktop” also known as the “Public desktop“.
  2. At C:\users<username>\desktop location.

In this blog post, we will check the steps for deploying a shortcut at both of these locations.

We will use a PowerShell script, which will be uploaded to Intune and deployed on end-user devices in System context. Let’s explore the step-by-step process for creating a desktop shortcut using Microsoft Intune.”

How To Delete A Desktop Shortcut Using Intune

Step-by-Step Guide

STEP 1 – Prepare Powershell scripts

Let’s use the Zoom app as an example, which has already been deployed on user’s devices. You can create a desktop shortcut either under C:\users\public\desktop or under C:\users<username>\desktop location.

  • Please note if Users desktop folder has been re-directed to OneDrive, Users desktop path where a shortcut will be created is: C:\Users\<username>\OneDrive – myorg\Desktop.
  • C:\users\public\desktop – When you create a desktop shortcut at this location, it will be available on the desktop of any user who will sign in to the device.
  • C:\users<username>\desktop or C:\Users\<username>\OneDrive – myorg\Desktop – This is the user’s profile desktop location. If you create a desktop shortcut at this location, it will be available only for that user.

Script to Deploy Desktop Shortcut on Public Desktop

  1. Update below variables in the script.
  • $TargetFile = Provide the target location of the shortcut. Update this variable to point it to the application executable.
  • $ShortcutFile = Specify where you’d like to create the shortcut and what name you’d like to give it. In this case, we’re going to create a desktop shortcut named “Zoom_New” on the Public desktop.
  • Copy and save below Powershell code in a file called: Zoom_shortcut.ps1.
$TargetFile = "C:\Program Files\Zoom\bin\Zoom.exe"
$ShortcutFile = "$env:Public\Desktop\Zoom_New.lnk"
$WScriptShell = New-Object -ComObject WScript.Shell
$Shortcut = $WScriptShell.CreateShortcut($ShortcutFile)
$Shortcut.TargetPath = $TargetFile
$Shortcut.Save()

Script to Deploy Desktop Shortcut on Users Desktop

Normally, the user’s desktop location is at C:\Users<username>\Desktop. But, if users desktop is re-directed to OneDrive, it will change to C:\Users<username>\OneDrive – myorg\Desktop.

  • $TargetFile = Provide the target location of the shortcut. Update this variable to point it to the application executable.
  • You can leave the $DesktopPath variable unchanged in the script. It automatically determines the correct user’s desktop path, eliminating the need for manual adjustments.
  • Copy and save below Powershell code in a file called: Zoom_shortcut.ps1
$TargetFile = "C:\Program Files\Zoom\bin\Zoom.exe"
$DesktopPath = [Environment]::GetFolderPath("Desktop")
$ShortcutFile = "$DesktopPath\Zoom_New.lnk"
$WScriptShell = New-Object -ComObject WScript.Shell
$Shortcut = $WScriptShell.CreateShortcut($ShortcutFile)
$Shortcut.TargetPath = $TargetFile
$Shortcut.Save()

STEP 2 – Deploy Powershell script

If you have prepared a Powershell script file then we can proceed to deploy it. Let’s check the steps:

  • Login on Intune Admin Center
  • Go to Devices -> Scripts.
  • Click on + Add and select Windows 10 and later.
Add a powershell script in Intune
Microsoft Endpoint Manager Admin Center –> Devices -> Scripts

Basics Tab

Provide a Name and Description of the profile. For Example:

  • Name: Create Zoom Desktop shortcut Icon
  • Description: This script will create a Zoom Desktop Shortcut Icon on Public Desktop.

Script Settings

On Script settings, you can browse to script location to upload into Intune.

  • Script Location: Browse to the location where your Powershell script is stored.
  • Run this script using the logged on credentials: Change it to No. As we will run this script in the System context, not the user context.
  • Enforce script signature check: Change it to No.
  • Run script in 64 bit Powershell Host: Select Yes. This will run powershell script in 64-bit mode.
Add Powershell Script on Microsoft Endpoint Manager Admin Center
Add Powershell Script on Microsoft Endpoint Manager Admin Center

Assignments

Click on Add Groups and add an Azure AD group containing Windows devices.

Review + Add

The final step is to review the information and click on Add to start the deployment process.

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

On the target device, PowerShell script will be downloaded at C:\Program Files (x86)\Microsoft Intune Management Extension\Policies\Scripts location before execution.

After Powershell script execution completes on the device, you will see a Desktop shortcut created under the C:\users\Public\Desktop location or under the path that you have configured in the deployment script.

Desktop Shortcut Created using Intune at C:\users\public\desktop location Intune
Desktop Shortcut Created using Intune at C:\users\public\desktop location

You can also verify Powershell script execution using IntuneManagementExtension.log log file located at C:\ProgramData\Microsoft\IntuneManagementExtension\Logs path. Make sure to open the most recent log file by using the Date modified column.

IntuneManagementExtension.log file showing the deployed Powershell script code
IntuneManagementExtension.log file showing the deployed Powershell script code

Powershell Script to Deploy Multiple Desktop Shortcuts

If you want to create more than one desktop shortcut on a user’s device. You can use the PowerShell script provided below. Customize the script to target the apps as per your requirements.

This script will create a desktop shortcut for Microsoft Excel, PowerPoint, Word, Outlook, Zoom, Edge browser, Chrome, and Onenote.

Please note that this script deploys the shortcuts to C:\users\public\desktop location. If you want to deploy the shortcut to the user’s desktop location then you will need to add a variable $desktopPath and update $shortcutfile variable to point to the $desktopPath location.

For Example:

$DesktopPath = [Environment]::GetFolderPath(“Desktop”)
$ShortcutFile = “$DesktopPath\Zoom_New.lnk”

Deploymultipleshortcuts.ps1

$TargetFile0  = "C:\Program Files\Microsoft Office\root\Office16\excel.exe"
$TargetFile1  = "C:\Program Files\Microsoft Office\root\Office16\winword.exe"
$TargetFile2  = "C:\Program Files\Microsoft Office\root\Office16\powerpnt.exe"
$TargetFile3  = "C:\Program Files\Microsoft Office\root\Office16\outlook.exe"
$TargetFile4  = "C:\Program Files\zoom\bin\Zoom.exe"
$TargetFile5  = "C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe"
$TargetFile6  = "C:\Program Files\Google\Chrome\Application\chrome.exe"
$TargetFile7  = "C:\Program Files\Microsoft Office\root\Office16\ONENOTE.EXE"
$ShortcutFile0  = "$env:Public\Desktop\Excel_1.lnk"
$ShortcutFile1  = "$env:Public\Desktop\Word_1.lnk"
$ShortcutFile2  = "$env:Public\Desktop\PowerPoint_1.lnk"
$ShortcutFile3  = "$env:Public\Desktop\Outlook_1.lnk"
$ShortcutFile4  = "$env:Public\Desktop\Zoom_1.lnk"
$ShortcutFile5  = "$env:Public\Desktop\Edge_1.lnk"
$ShortcutFile6  = "$env:Public\Desktop\Chrome_1.lnk"
$ShortcutFile7  = "$env:Public\Desktop\OneNote_1.lnk"
$WScriptShell0 = New-Object -ComObject WScript.Shell
$WScriptShell1 = New-Object -ComObject WScript.Shell
$WScriptShell2 = New-Object -ComObject WScript.Shell
$WScriptShell3 = New-Object -ComObject WScript.Shell
$WScriptShell4 = New-Object -ComObject WScript.Shell
$WScriptShell5 = New-Object -ComObject WScript.Shell
$WScriptShell6 = New-Object -ComObject WScript.Shell
$WScriptShell7 = New-Object -ComObject WScript.Shell
$Shortcut0 = $WScriptShell0.CreateShortcut($ShortcutFile0)
$Shortcut1 = $WScriptShell1.CreateShortcut($ShortcutFile1)
$Shortcut2 = $WScriptShell2.CreateShortcut($ShortcutFile2)
$Shortcut3 = $WScriptShell3.CreateShortcut($ShortcutFile3)
$Shortcut4 = $WScriptShell4.CreateShortcut($ShortcutFile4)
$Shortcut5 = $WScriptShell5.CreateShortcut($ShortcutFile5)
$Shortcut6 = $WScriptShell6.CreateShortcut($ShortcutFile6)
$Shortcut7 = $WScriptShell7.CreateShortcut($ShortcutFile7)
$Shortcut0.TargetPath = $TargetFile0
$Shortcut1.TargetPath = $TargetFile1
$Shortcut2.TargetPath = $TargetFile2
$Shortcut3.TargetPath = $TargetFile3
$Shortcut4.TargetPath = $TargetFile4
$Shortcut5.TargetPath = $TargetFile5
$Shortcut6.TargetPath = $TargetFile6
$Shortcut7.TargetPath = $TargetFile7
$Shortcut0.Save()
$Shortcut1.Save()
$Shortcut2.Save()
$Shortcut3.Save()
$Shortcut4.Save()
$Shortcut5.Save()
$Shortcut6.Save()
$Shortcut7.Save()

Conclusion

In this blog post, we’ve explored the process of deploying a desktop shortcut on end-user devices. You have two location options for creating a desktop shortcut:

  1. Option 1: Public Desktop (Recommended):
    • Creating a desktop shortcut at C:\users\public\deskop is the recommended choice. This ensures that the shortcut is visible to all users who use that device.
  2. Option 2: User’s Profile Desktop:
    • Alternatively, you can deploy a desktop shortcut to the user’s profile desktop, which could be located at C:\users<username>\desktop or C:\Users\<username>\OneDrive – myorg\Desktop. Shortcuts placed in the user’s profile will only be visible to that specific user.

These options allow you to control the visibility and accessibility of desktop shortcuts based on your specific needs.

3 thoughts on “How to create a desktop shortcut using Intune”

  1. This works but it is saving the shortcut to the root of C:\ and not the desktop path. What is weird is running this from powershell from a device puts it perfectly on the desktop. But there is something about this running through Intune where it seems to not resolve the desktop path?

    Reply
    • Hi Martin,

      When you are creating desktop shortcuts on User’s OneDrive desktop, Are you executing the script using logged on user’s credentials / User Context ?

      Try Setting Run this Script using logged on credentials in Script Settings to Yes.

      Reply
  2. Hello,

    I’ve tried to import a similar script (that works manually when you execute it yourself through powershell) in intune so word and chrome can have shortcut on the desktop, but the script always fails. i have tried to make the script wait 30 min and then execute the code, i tried to execute it instantly when autopilot read the script, and another that check if a installation is still going (if yes, it wait 10s and re check if there is an installation) but this one is not working i guess.

    So, i don’t understand why it works manually but not with autopilot. Do you have an idea ?

    Reply

Leave a Comment

Discover more from TechPress

Subscribe now to keep reading and get access to the full archive.

Continue reading