From a4a09819a01ab8d54d51534de10ef66d1eb78b71 Mon Sep 17 00:00:00 2001 From: Markus Fleschutz Date: Fri, 1 Oct 2021 13:03:02 +0200 Subject: [PATCH] Update check-symlinks.ps1 --- Scripts/check-symlinks.ps1 | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Scripts/check-symlinks.ps1 b/Scripts/check-symlinks.ps1 index b950fc57..3e6f063f 100755 --- a/Scripts/check-symlinks.ps1 +++ b/Scripts/check-symlinks.ps1 @@ -2,7 +2,7 @@ .SYNOPSIS check-symlinks.ps1 [] .DESCRIPTION - Checks every symlink in a directory tree + Checks every symlink in a directory tree. .EXAMPLE PS> ./check-symlinks C:\MyApp .LINK @@ -16,9 +16,10 @@ param([string]$DirTree = "") try { if ($DirTree -eq "" ) { $DirTree = read-host "Enter the path to the directory tree" } - write-progress "Checking symlinks in $DirTree..." + $FullPath = Resolve-Path "$DirTree" + write-progress "Checking every symlink in 📂$FullPath..." [int]$NumTotal = [int]$NumBroken = 0 - Get-ChildItem $DirTree -recurse | Where { $_.Attributes -match "ReparsePoint" } | ForEach-Object { + Get-ChildItem $FullPath -recurse | Where { $_.Attributes -match "ReparsePoint" } | ForEach-Object { $Symlink = $_.FullName $Target = ($_ | Select-Object -ExpandProperty Target -ErrorAction Ignore) if ($Target) { @@ -32,7 +33,7 @@ try { $NumTotal++ } - "✔️ $NumBroken out of $NumTotal symlinks are broken in 📂$DirTree" + "✔️ $NumBroken out of $NumTotal symlinks are broken in 📂$FullPath" exit $NumBroken } catch { "⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))"