Check Broken Shorcuts (Logged on User)

Hey,

A simple tool I use to check broken shorcuts on remote computers, for the logged on user.

You can modify "$env:USERPROFILE" if needed and adjust comments from French.

 

Code:

$Shortcuts = Get-ChildItem -Recurse $env:USERPROFILE\desktop\ -Include *.lnk

$Shell = New-Object -ComObject WScript.Shell
foreach ($Shortcut in $Shortcuts)
{
$Properties = @{
ShortcutName = $Shortcut.Name
Path = $Shortcut.FullName
ShortcutDirectory = $Shortcut.DirectoryName
Target = $Shell.CreateShortcut($Shortcut).targetpath
}
New-Object PSObject -Property $Properties
}

$retour = Foreach ($Shortcut in $Shortcuts)
{Test-Path $Properties.Target}

If ($retour -eq $false){
Write-Output "Raccourcis invalides ! :("

}Else{
Write-Output "Pas de mauvais raccourcis trouves ! :)"

}

 

Screenshots :

 

Good Output :

 

Bad output :

 

Enjoy !

 

2

Comments

0 comments

Please sign in to leave a comment.

Didn't find what you were looking for?

New post