This article will describe how to deploy custom URL shortcuts with Microsoft Intune.
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 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 is very simple:
$new_object = New-Object -ComObject WScript.Shell
$destination = $new_object.SpecialFolders.Item("AllUsersDesktop")
$source_path = Join-Path -Path $destination -ChildPath "\\Salesforce.url"
$source = $new_object.CreateShortcut($source_path)
$source.TargetPath = "http://login.salesforce.com"
$source.Save()
This Powershell script creates a custom URL shortcut and places it in the Public Desktop folder of your Windows 10 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
Copy the code above and copy it into an editor like Powershell ISE or Visual Studio Code.
Change the following as preferred (in this example we will deploy Salesforce URL to our desktop).

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.
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?
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