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 🙂

#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

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s