mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-04-20 08:58:18 +02:00
Update check-symlinks.ps1
This commit is contained in:
parent
bcb66d2445
commit
e71741d12a
@ -1,6 +1,6 @@
|
|||||||
<#
|
<#
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
Checks every symlink in a folder
|
Checks symlinks in a directory tree
|
||||||
.DESCRIPTION
|
.DESCRIPTION
|
||||||
This PowerShell script checks every symlink in a folder (including subfolders).
|
This PowerShell script checks every symlink in a folder (including subfolders).
|
||||||
It returns the number of broken symlinks as exit value.
|
It returns the number of broken symlinks as exit value.
|
||||||
@ -22,7 +22,7 @@ try {
|
|||||||
|
|
||||||
$StopWatch = [system.diagnostics.stopwatch]::startNew()
|
$StopWatch = [system.diagnostics.stopwatch]::startNew()
|
||||||
$FullPath = Resolve-Path "$folder"
|
$FullPath = Resolve-Path "$folder"
|
||||||
"⏳ Checking every symlink in 📂$FullPath ..."
|
"⏳ Checking symlinks under 📂$FullPath ..."
|
||||||
|
|
||||||
[int]$NumTotal = [int]$NumBroken = 0
|
[int]$NumTotal = [int]$NumBroken = 0
|
||||||
Get-ChildItem $FullPath -recurse | Where { $_.Attributes -match "ReparsePoint" } | ForEach-Object {
|
Get-ChildItem $FullPath -recurse | Where { $_.Attributes -match "ReparsePoint" } | ForEach-Object {
|
||||||
@ -32,7 +32,7 @@ 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) {
|
||||||
"Bad $Symlink 🠆 $Target"
|
"$Symlink 🠆 $Target is broken"
|
||||||
$NumBroken++
|
$NumBroken++
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user