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