Improved check-symlinks.ps1

This commit is contained in:
Markus Fleschutz 2021-02-10 16:57:03 +01:00
parent 43eb1283db
commit cf7b28a93f

View File

@ -21,13 +21,13 @@ try {
$path = $_.FullName + "\..\" + ($_ | Select-Object -ExpandProperty Target)
$item = Get-Item $path -ErrorAction Ignore
if (!$item) {
write-output "Symlink $Symlink -> $Target is broken"
write-warning "Broken symlink: $Symlink -> $Target"
$SymlinksBroken++
}
}
$SymlinksTotal++
}
echo "Done - found $SymlinksTotal symlinks total, $SymlinksBroken are broken"
write-output "Done - found $SymlinksTotal symlinks total, $SymlinksBroken are broken"
exit $SymlinksBroken
} catch {
write-error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"