Creating a web page shortcut on the desktop using intune

In this blog I want to explain how you can create a shortcut to a website on the desktop with the help of Intune. You can use this for example to make the opening of your company’s intranet site or web application faster and easier for the users.

All the scripts I use in this blog can be found in my Git repository: Create-DesktopShortcut

Creating the desktop shortcut

With the following script you can create a shortcut file: Create-ShortcutFile.ps1

Before you run this script you have to edit it. For this adjust the following variables:

#Name of the shortcut
$shortcutName = "Intranet Shortcut" 
#Icon file best to use a website
$icon = "https://jannikreinhard.files.wordpress.com/website.ico"
#Link of the webseite
$websiteUrl = "https://jannikreinhard.com/"
#OutputFolder
$outputFolder = "C:\temp"

Hint: If you want to use the Windows shell icons you can do this with the following path in the icon variable.

%SystemRoot%\System32\SHELL32.dll,27

Once you have adjusted these variables you can create the .lnk file by running the script. You will find this file in the path you specified in the $outputFolder variable.

Creating the needed Scripts

We need to create 3 scripts to deploy the application through Intune. An installation, uninstallation and detection script is needed. Where you can find the scripts and how you need to customize them I will explain now.

Installation Script

To copy the shortcut to all users desktop we have to create the installation powersehll script. This script can be found here.

#Name of the shortcut
$shortcutName = "Intranet Shortcut" 

$ScriptPath = [System.IO.Path]::GetDirectoryName($MyInvocation.MyCommand.Definition)

Copy-Item -Path "$ScriptPath\$shortcutName.lnk" -Destination "$Env:Public\Desktop"

Edit this script and insert the name you chose for the shortcut into the $shortcutName variable.

#Name of the shortcut
$shortcutName = "Intranet Shortcut" 

Deinstallation Script

After this script is created we need an uninstallation script. You can also find this in my repository.

#Name of the shortcut
$shortcutName = "Intranet Shortcut" 

Remove-Item -Path "$Env:Public\Desktop\$shortcutName.lnk"

Also here the $shortcutName variable must be adjusted.

#Name of the shortcut
$shortcutName = "Intranet Shortcut" 

Detection Script

Here you can find the detection script: Get-DesktopShortcut.ps1

#Name of the shortcut
$shortcutName = "Intranet Shortcut"  

if (Test-Path -Path "$Env:Public\Desktop\$shortcutName.lnk"){
    Write-Output "0"
}

The name of the shortcut must also be entered here.

#Name of the shortcut
$shortcutName = "Intranet Shortcut" 

Creating the Intune application file

How to create an Intune Application (.intunewin file) I have explained in detail in my blog using the CMtrace example. You can also find more information in the Microsoft Docs.

  • Create a folder in which you can place the shortcut and the installation and uninstallation scripts.
  • Open a CMD as admin an run the following command:
.\IntuneWinAppUtil -c C:\temp\IntranetShortcut -s C:\temp\IntranetShortcut\Create-DesktopShortcut.ps1 -o C:\temp\

Creating the Win32 App in intune

  • Navigate to Apps -> Windows
  • Click Add
  • Select Windows app (Win32) as App type
  • Click Select app package file
  • Click upload und select the .intunewin file
  • Click OK
  • Give the application a name and customize the app information.
  • Click Next
  • Enter the following as installation and uninstallation command

Install Command:

%windir%\system32\windowspowershell\v1.0\powershell.exe -executionpolicy bypass -windowstyle hidden -file "Create-DesktopShortcut.ps1"

Unistall Command:

%windir%\system32\windowspowershell\v1.0\powershell.exe -executionpolicy bypass -windowstyle hidden -file "Delete-DesktopShortcut.ps1"
  • Change the Device restart behavior to No specific action
  • Click Next
  • Select 32-bit and 64-bit as Operation system architecture
  • Select a minimum OS Version

Hints: If you want to specify further requirements, such as minimum free disk space, you can do this in this step.
It is also possible to specify a file, a registry value or a script as a requirement.

  • Select Use a custom detection script as Rules format
  • Upload the detection script
  • Click Next
  • We can skip the depentencies and supersedence step click next.
  • Add a assignment. In my example I have selected all default devices.
  • Click Next > Create

Now the shortcut is distributed to all computers in the group. As soon as the application package has arrived and is installed on the computers, you should find the shortcut on the desktop.

Stay healthy, Cheers
Jannik

One thought on “Creating a web page shortcut on the desktop using intune

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s