Delete shortcut pointing to a specific URL

There will be cases where some users are asked to test a dev/training webapp. Few of these users tend to create shortcuts/bookmark to the dev/training webapp and still keep using the dev even after the webapp was rolled to production.
Desktop guys to rescue to clean out these shortcuts or bookmarks 🙂
[code language=”css” title=”Powershell Code” highlight=”3,4,5,8″]
#Clean up RL Solutions Training Link
$ws = New-Object -comObject WScript.Shell
$Favorites = [System.Environment]::GetFolderPath(‘favorite’)
$Desktop = [System.Environment]::GetFolderPath(‘Desktop’)
dir $Desktop,$Favorites -Recurse -filter *.url | % {
$URL = $ws.CreateShortcut($($_.FullName))
#Check if the url contains the word "RL6_Training"
if($($URL.TargetPath).Contains("RL6_Training") )
{
#Delete
Remove-Item ($_.FullName) -Force
}
}
#Close comObject
Remove-Variable ws
[/code]

Leave a comment

Your email address will not be published. Required fields are marked *

WordPress Appliance - Powered by TurnKey Linux