This article will describe how to deploy custom URL shortcuts with Microsoft Intune.
05/10/2022 UPDATE: added some adjustments to the script and also added the possibility to add a custom icon.
Welcome to my first post in my “Cases from the Field” series. This series will describe things I’ve done during the projects I’ve worked on as a Modern Workplace Consultant.
Let me briefly describe what our customer requested. They use 2 web applications and want them as a URL shortcut on their Windows 10/11 enrolled device. Instead of doing this manually for all their devices, they asked if it is possible to do this with Microsoft Intune.
To make this possible I’ve deployed a Powershell script with Microsoft Intune. The script (updated version with custom icon) is very simple:
#Variables creating local folder and download .ico file
$LocalIconFolderPath = "C:\URLIcon"
$SourceIcon = "http://nickydewestelinck.be/wp-content/icons/salesforce.ico"
$DestinationIcon = "C:\URLIcon\salesforce.ico"
#Step 1 - Create a folder to place the URL icon
New-Item $LocalIconFolderPath -Type Directory
#Step 2 - Download a ICO file from a website into previous created folder
curl $SourceIcon -o $DestinationIcon
#Step 3 - Add the custom URL shortcut to your Desktop with custom icon
$new_object = New-Object -ComObject WScript.Shell
$destination = $new_object.SpecialFolders.Item('AllUsersDesktop')
$source_path = Join-Path -Path $destination -ChildPath '\\Salesforce.lnk'
$source = $new_object.CreateShortcut($source_path)
$source.TargetPath = 'https://login.salesforce.com'
$source.IconLocation = ”C:\URLIcon\salesforce.ico”
$source.Save()
This Powershell script creates a custom URL shortcut with custom icon and places it in the Public Desktop folder of your Windows 10/11 device. In this case, it will place a URL shortcut “Salesforce” and this will go to https://login.salesforce.com/

How to deploy custom URL shortcut with Microsoft Intune
Now let me show you how to deploy this Powershell Script with Microsoft Intune.
Step 1: Create a Powershell Script (Updated)
This part of the article is an updated version. I’ve added a three extra steps, the first one or some variables we need to download and add an icon into a newly created folder locally. Be sure that your icon file is a .ico extension, I use X-Icon Editor (xiconeditor.com) to create/convert my image into a, .ico file and then upload them to my site. You can also use Azure blob storage to store your icon files.
For example, these are the variables:
#Variables creating local folder and download .ico file
$LocalIconFolderPath = "C:\URLIcon"
$SourceIcon = "http://nickydewestelinck.be/wp-content/icons/salesforce.ico"
$DestinationIcon = "C:\URLIcon\salesforce.ico"
Step 1 will create a folder on your device, it will be located at C:\URLIcon\.
#Step 1 - Create a folder to place the URL icon
New-Item $LocalIconFolderPath -Type Directory
Step 2 will download the .ico file and create one locally in the previously created folder. We use cURL for this part, more information here on cURL.
#Step 2 - Download a ICO file from a website into previous created folder
curl $SourceIcon -o $DestinationIcon
The last part will create the URL shortcut, with the custom icon, to the Public Desktop folder on the device.
#Step 3 - Add the custom URL shortcut to your Desktop with custom icon
$new_object = New-Object -ComObject WScript.Shell
$destination = $new_object.SpecialFolders.Item('AllUsersDesktop')
$source_path = Join-Path -Path $destination -ChildPath '\\Salesforce.lnk'
$source = $new_object.CreateShortcut($source_path)
$source.TargetPath = 'https://login.salesforce.com'
$source.IconLocation = ”C:\URLIcon\salesforce.ico”
$source.Save()
Copy the code above and copy it into an editor like Powershell ISE or Visual Studio Code.
#Variables creating local folder and download .ico file
$LocalIconFolderPath = "C:\URLIcon"
$SourceIcon = "http://nickydewestelinck.be/wp-content/icons/salesforce.ico"
$DestinationIcon = "C:\URLIcon\salesforce.ico"
#Step 1 - Create a folder to place the URL icon
New-Item $LocalIconFolderPath -Type Directory
#Step 2 - Download a ICO file from a website into previous created folder
curl $SourceIcon -o $DestinationIcon
#Step 3 - Add the custom URL shortcut to your Desktop with custom icon
$new_object = New-Object -ComObject WScript.Shell
$destination = $new_object.SpecialFolders.Item('AllUsersDesktop')
$source_path = Join-Path -Path $destination -ChildPath '\\Salesforce.lnk'
$source = $new_object.CreateShortcut($source_path)
$source.TargetPath = 'https://login.salesforce.com'
$source.IconLocation = ”C:\URLIcon\salesforce.ico”
$source.Save()
Now save this PowerShell script to your local computer as a .ps1 file. I named it Create-Desktop-URL-Shortcuts.ps1.
Step 2: Deploy script with Microsoft Intune
Go to https://endpoint.microsoft.com and sign-in with a Global Administrator or Intune Administrator.
Go to Devices => Scripts. Then click on +Add and choose for Windows 10.

Give the Script a name. In this example it will be NDW – Add Custom URL shortcut to Desktop and click Next.

Choose the PowerShell script created and saved in Step 1. Leave the extra settings as default.

Assign it to All Devices or a group to those who need the deployment and click Next.

Review your settings and click Add. Your script will now be added.

Your script is now added and ready to deploy to the requested devices.

So this is how to deploy custom URL shortcuts with Microsoft Intune. Isn’t that difficult is it?
So this was the first post in my “Cases from the Field” series. Stay tuned for more…
Any way to have this force use Internet Explorer? I have some legacy apps that only launch from IE.
Sorry for my late reaction! Currently I’ve only done this for Microsoft Edge.
Edge y compatibilidad con IE y la versión, y agregar la condición.
Excellent, is there any way to add a custom icon ?
You can try by adding an extra line to the script.
$source.IconLocation=”iconfile.ico, 0″
Hi. I too want to add a custom logo, but get this error after trying to add the additional line:
Exception setting “IconLocation”: “The property ‘IconLocation’ cannot be found on this object. Verify that the property exists and can be set.
Can you or any of your readers please suggest a fix?
Is your icon location path available from the device? Can you provide a screenshot of your script?
Kan je ook bij logo locatie de URL doen waar het logo staat ?
Hi Levin,
Gonna answer this in English if you don’t mind. Didn’t tried it myself but I think a URL should work to, as long it’s publically reachable.
Regards,
Nicky
Didn’t work. I did this by example on powershell.
$source.IconLocation= ”https://www.voys.nl/app/themes/voys/dist/images/logo.svg”
Can you see the problem??
Hi Levin,
Apologies for the late reaction, but I was on Holiday. I tried it myself, but it seems that the URLs aren’t working.
I going to try to make some time to check out a solution by creating a W32 app. I’ll keep you posted.
Hi Levin,
I’ve updated the script, but be sure to convert your .svg file to a .ico file. I used this this site => https://www.xiconeditor.com/.
And instead of using the .URL in the link, you should change it to .lnk. That’s why the IconLocation property doesn’t work.
I added some extra lines to the script. Steps are explained in the title. I’ve tested it in Sandbox and it worked.
#Step 1 – Create a folder to place the URL icon
New-Item “C:\URLIcon” -Type Directory
#Step 2 – Download a ICO file from a website into previous created folder
curl “http://nickydewestelinck.be/wp-content/icons/favicon.ico” -o C:\URLIcon\salesforce.ico
#Step 3 – Add the custom URL shortcut to your Desktop with custom icon
$new_object = New-Object -ComObject WScript.Shell
$destination = $new_object.SpecialFolders.Item(‘Desktop’)
$source_path = Join-Path -Path $destination -ChildPath ‘\\Salesforce.lnk’
$source = $new_object.CreateShortcut($source_path)
$source.TargetPath = ‘http://login.salesforce.com’
$source.IconLocation = ”C:\URLIcon\salesforce.ico”
$source.Save()
Regards,
Nicky
Thanks for your info. If i deploy my script in Intune it doesn’t work. The script created a directory with the icon but the shortcut self isn’t visible. They only thing what is maybe the problem is that or organization policy blocked it. I think that is not the problem because without the icon the script works totally. Any idea what is happening??
Can you show me your full script?
If users don’t have elevated privileges will it still add the shortcut without admin rights?
Normally it should do the trick. 🙂
+My company has Android and Apple devices in Intune. I’ve been tasked with pushing a company website shortcut to all the Apple devices. I tried the script and it immediately says the uploaded file isn’t a valid script. Is there a wayto do this for iOs devices in Intune?
This post is for Windows 10/11 devices and won’t work on iOS devices. Not sure if this is possible for iOS in Intune.
Hi, thanks for the post. is there a universal repository of icons url hosted online that can be used to replace the internet explorer logo? If you know of any kindly point
Not that I know off, but interesting question. Something I need to figure out. 🙂
script is working fine but it is opening in Edge browser, Please suggest, how I can set it as Chrome instead of Edge.
Is Chrome set as the default browser on your client? This script normally uses the default browser of the client and not just Microsoft Edge.
I would love to use this for creating shortcuts but, when I try to run the script in step 1 in an elevated Powershell window I just get the following error:-
Unable to save shortcut “C:\Users\Public\Desktop\Salesforce.url”.
At line:7 char:1
+ $source.Save()
+ ~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (:) [], COMException
+ FullyQualifiedErrorId : System.Runtime.InteropServices.COMException
Any ideas on how to resolve this?
Many thanks in advance.
Hi Mike,
Apologies for my late response, I was on vacation for two weeks. 🙂
I just tried the script and (for some odd reason) I received the same error. I managed to get it working by changing the $destination variable to “Desktop” instead of “AllUsersDesktop”.
This worked for me, here is the “new script”.
$new_object = New-Object -ComObject WScript.Shell
$destination = $new_object.SpecialFolders.Item(“Desktop”)
$source_path = Join-Path -Path $destination -ChildPath “\\Salesforce.url”
$source = $new_object.CreateShortcut($source_path)
$source.TargetPath = “http://login.salesforce.com”
$source.Save()
Greetings,
Nicky
Hi,
Can i add more than one shortcut using the above script??
Hi,
Yes you can. Just copy these commands multiple times in the same script and change the path. For example:
# Add Salesforce Shortcut
$new_object = New-Object -ComObject WScript.Shell
$destination = $new_object.SpecialFolders.Item(“Desktop”)
$source_path = Join-Path -Path $destination -ChildPath “\\Salesforce.url”
$source = $new_object.CreateShortcut($source_path)
$source.TargetPath = “http://login.salesforce.com”
$source.Save()
#Add Google shortcut
$new_object = New-Object -ComObject WScript.Shell
$destination = $new_object.SpecialFolders.Item(“Desktop”)
$source_path = Join-Path -Path $destination -ChildPath “\\Google.url”
$source = $new_object.CreateShortcut($source_path)
$source.TargetPath = “http://www.google.com”
$source.Save()
Greetings,
Nicky
Hi Nicky
How we can delete the shortcut?
Thanks
Roni
You can create a second script with a delete command and assign it to users who don’t need the shortcut anymore.
Regards.
Hi Nicky,
Thanks for the script! Is there a line of code or a way to ensure that if an existing shortcut with the same name, i.e. salesforce.url is already present, to overwrite this rather than creating an additional one?
Hi Tommy,
Not for now, need to check this out.
Regards.
Thanks Nicky! Just in time for my customer. 🙂
Hi Nicky,
I’m able to run local with elevated privileges but this fails as per you script settings. I even select to run on 64bit host as this works on some scripts I’ve deployed via Intune.
Any suggestions?
Thank you!
Hi,
Can you try this script?
$new_object = New-Object -ComObject WScript.Shell
$destination = $new_object.SpecialFolders.Item(“Desktop”)
$source_path = Join-Path -Path $destination -ChildPath “\\Salesforce.url”
$source = $new_object.CreateShortcut($source_path)
$source.TargetPath = “http://login.salesforce.com”
$source.Save()
Regards.
Nicky,
Great script and works like a champ, but I would like to ask about icon again. So I can add the icon file and the extra line to the script, but I would like a suggestion from you. Since the whole point is to push this from InTune, then, in theory, there is no on-prem servers for things like storage of .ico files. If you had no file/DC servers, where in Azure would you store the .ico file itself?
Appreciate any recommendations,
Brian
Hi Brian,
You could try using Azure Blob Storage for this.
https://docs.microsoft.com/en-us/azure/storage/blobs/storage-blobs-introduction
Greetz,
Nicky
Hi Nicky,
First of all, thank you for the code, it was exactly what I was looking for and it works brilliantly. Now for the second part, on how to delete previously added links, by googling I found something like this:
$Icon1 = “Salesforce.lnk”
If ((Test-Path “$env:AllUsers\Desktop\$Icon1”) -eq $true)
{
Remove-Item “$($env:AllUsers)\Desktop\$Icon1” –Force
}
Would something like this work?
Regards
Hi Salvatore,
Big thanks for your feedback, it’s much appreciated! 😉
What I always do for testing such scripts is, open Windows Sandbox and run those scripts there.
The first step is to run the script that creates the link (as written in the blog), then run your script (the one above) to see if the link is removed. If it’s the case, I think your script works perfectly and you can deploy it. 😉
Regards!
Hi,
My script is a bit different, but it does the same thing. When i manually execute it on the desktop , it works perfectly fine, but in the deployment with intune autopilot, it break because it try to put the shortcut in this :
“C:\WINDOWS\system32\config\systemprofile\Desktop\Google-Chrome.lnk”.
I think that it try to put shortcut while being in a special profil for installing so he don’t find the right profil. Here is my script :
$shell = New-Object -ComObject WScript.Shell
$appName = “Google-Chrome”
$appPath = “C:\Program Files\Google\Chrome\Application\chrome.exe”
$iconPath = $appPath
# Récupération du chemin du profil utilisateur
$userProfile = $env:USERPROFILE
$lg = “Desktop”
$shortcutPath = “$userProfile\$lg\$appName.lnk”
$shortcut = $shell.CreateShortcut($shortcutPath)
$shortcut.TargetPath = $appPath
$shortcut.IconLocation = $iconPath
$shortcut.Save()
$appName = “Wordd”
$appPath = “C:\Program Files\Microsoft Office\root\Office16\WINWORD.exe”
$iconPath = $appPath
# Récupération du chemin du profil utilisateur
$userProfile = $env:USERPROFILE
$shortcutPath = “$userProfile\$lg\$appName.lnk”
$shortcut = $shell.CreateShortcut($shortcutPath)
$shortcut.TargetPath = $appPath
$shortcut.IconLocation = $iconPath
$shortcut.Save()
# RAJOUTER \OneDrive\ ENTRE USERPROFILE ET LG SI L’UTILISATEUR VA UTILISER ONEDRIVE
Hi There,
I have managed to deploy a shortcut to my desktop following your guide. It also has a custom Icon which is great. Intune has pushed this out perfectly.
however, when double clicking the shortcut on my desktop it comes up with “Missing Shortcut”? Have I done something wrong? This is the code I have used! Any help will be much appreciated.
I also have a URLIcon on my C Drive containing the .ico file.
“FYI Line 3 SourceIcon I have removed the blob storage URL for security reasons on this feed. But rest assured its in there when deploying the script!”
#Variables creating local folder and download .ico file
$LocalIconFolderPath = “C:\URLIcon”
$SourceIcon = “Removed”
$DestinationIcon = “C:\URLIcon\Ulysses Incident Reporting.ico”
#Step 1 – Create a folder to place the URL icon
New-Item $LocalIconFolderPath -Type Directory
#Step 2 – Download a ICO file from a website into previous created folder
curl $SourceIcon -o $DestinationIcon
#Step 3 – Add the custom URL shortcut to your Desktop with custom icon
$new_object = New-Object -ComObject WScript.Shell
$destination = $new_object.SpecialFolders.Item(‘AllUsersDesktop’)
$source_path = Join-Path -Path $destination -ChildPath ‘\\Ulysses Incident Reporting.lnk’
$source = $new_object.CreateShortcut($source_path)
$source.TargetPath = ‘ulysses.everyturn.org’
$source.IconLocation = ”C:\URLIcon\Ulysses Incident Reporting.ico”
$source.Save()
Hi Guys, sorry never mind I have got it working! I didnt put in the https:// at the front of my URL
This is now resolved. Thanks for your help!!
Hi Chris,
You beat me to it. 😉 This was exactly what I was trying to suggest.
Glad to hear I could help!
Kind regards,
Nicky