diff --git a/scripts/powershell/common.ps1 b/scripts/powershell/common.ps1 index c67097773..7a96d3fac 100644 --- a/scripts/powershell/common.ps1 +++ b/scripts/powershell/common.ps1 @@ -8,7 +8,8 @@ function Find-SpecifyRoot { # Normalize to absolute path to prevent issues with relative paths # Use -LiteralPath to handle paths with wildcard characters ([, ], *, ?) - $current = (Resolve-Path -LiteralPath $StartDir -ErrorAction SilentlyContinue)?.Path + $resolved = Resolve-Path -LiteralPath $StartDir -ErrorAction SilentlyContinue + $current = if ($resolved) { $resolved.Path } else { $null } if (-not $current) { return $null } while ($true) {