π Persistent Corporate Desktop Shortcuts with Custom Icons (PowerShell + Intune)
π‘ Why This Is Useful
Ever needed to add desktop links to company resources - ones users canβt easily delete - with customised icons?
This lightweight approach lets you:
- π Keep shortcuts consistent across all devices
- π Prevent accidental deletion by end users
- β¨ Deploy easily with Intune Win32 apps
π¦ How It Works
- Creates shortcuts on the Public Desktop with your custom icon.
- Stores all icons in a shared folder:
C:\ProgramData\DesktopShortcuts
- Automatically cleans up the folder when the last link is removed.
π Customisation
Just replace the:
$url
β your linkgoogle.ico
β your custom icon fileGoogle.lnk
β your shortcut name
β οΈ Important: Ensure the icon file and the scripts are in the same folder.
π₯ Installer Script
# Variables
$url = "https://www.google.co.uk/"
$scriptDirectory = Split-Path -Parent $MyInvocation.MyCommand.Definition
$tempIconPath = Join-Path $scriptDirectory "google.ico"
$persistentIconPath = "C:\ProgramData\DesktopShortcuts\google.ico"
$shortcutPath = "C:\Users\Public\Desktop\Google.lnk"
# Ensure destination directory exists
$persistentDir = Split-Path $persistentIconPath
if (-not (Test-Path $persistentDir)) {
New-Item -Path $persistentDir -ItemType Directory -Force | Out-Null
}
# Copy icon to permanent location
Copy-Item -Path $tempIconPath -Destination $persistentIconPath -Force
# Create shortcut
$shell = New-Object -ComObject WScript.Shell
$shortcut = $shell.CreateShortcut($shortcutPath)
$shortcut.TargetPath = $url
$shortcut.IconLocation = $persistentIconPath
$shortcut.Save()
Write-Host "Shortcut created with persistent icon at $shortcutPath"
π₯ Uninstaller Script
# Variables
$persistentIconPath = "C:\ProgramData\DesktopShortcuts\google.ico"
$shortcutPath = "C:\Users\Public\Desktop\Google.lnk"
$persistentDir = Split-Path $persistentIconPath
# Remove shortcut
if (Test-Path $shortcutPath) {
Remove-Item $shortcutPath -Force
Write-Host "Removed shortcut: $shortcutPath"
}
# Remove icon
if (Test-Path $persistentIconPath) {
Remove-Item $persistentIconPath -Force
Write-Host "Removed icon: $persistentIconPath"
}
# Clean up folder if empty
if (Test-Path $persistentDir -and !(Get-ChildItem $persistentDir)) {
Remove-Item $persistentDir -Force
Write-Host "Removed folder: $persistentDir"
} else {
Write-Host "Folder not empty or does not exist, skipping deletion: $persistentDir"
}
π¦ Deployment Tip
- Package and add two script files and the icon file as a Win32 app in Intune.
- Use the uninstaller script for clean removal.
- You can use the .lnk fileβs existence in the Public Desktop folder as the detection method.
β¨ With this method, your corporate desktop stays clean, consistent and professional - no matter who logs in!