top of page
Search

(188) Microsoft Intune - Remove Shortcuts (*.lnk) on Public Desktop

  • Writer: Mr B SOE way
    Mr B SOE way
  • 3 hours ago
  • 1 min read

A customer reached out to me as they wanted to prevent shortcuts (*.lnk) from appearing on their student devices.


Easiest I could think of is a detect and remediation script.



$Shortcuts2Remove = "Google Chrome.lnk", "VLC media player.lnk", "Audacity.lnk", "Firefox.lnk", "Google Chrome.lnk", "Microsoft Edge.lnk", "Vivi.lnk"
$DesktopPath = "C:\Users\Public\Desktop" # Public and User Desktop: "C:\Users\*\Desktop\*", for Public Desktop shortcuts only: "C:\Users\Public\Desktop" 
$ShortcutsOnClient = Get-ChildItem $DesktopPath
$ShortcutsUnwanted = $ShortcutsOnClient | Where-Object -FilterScript {$_.Name -in $Shortcuts2Remove }

if (!$ShortcutsUnwanted) {
	Write-Host "All good, no shortcuts found. "
	exit 0
}else{
	Write-Host "Unwanted shortcut detected."
	Exit 1
}

$Shortcuts2Remove = "Google Chrome.lnk", "VLC media player.lnk", "Audacity.lnk", "Firefox.lnk", "Google Chrome.lnk", "Microsoft Edge.lnk", "Vivi.lnk"
$DesktopPath = "C:\Users\Public\Desktop" # Public and User Desktop: "C:\Users\*\Desktop\*", for Public Desktop shortcuts only: "C:\Users\Public\Desktop" 
$ShortcutsOnClient = Get-ChildItem $DesktopPath

try{
    $($ShortcutsOnClient | Where-Object -FilterScript {$_.Name -in $Shortcuts2Remove }) | Remove-Item -Force
    Write-Host "Unwanted shortcut(s) removed."
}catch{
    Write-Error "Error removing shortcut(s)"
}

For Remediation settings, set the following:

Run this script using the logged-on credentials: No

Enforce script signature check: No

Run script in 64-bit PowerShell: No

ree

All my scripts can be found here in Github.


 
 
 

Comments


bottom of page