diff --git a/Scripts/check-ps1-file.ps1 b/Scripts/check-ps1-file.ps1 index 68b96be4..ff0a35c8 100644 --- a/Scripts/check-ps1-file.ps1 +++ b/Scripts/check-ps1-file.ps1 @@ -2,7 +2,7 @@ .SYNOPSIS Checks PowerShell file(s) for validity .DESCRIPTION - This PowerShell script checks the given PowerShell file(s) for validity. + This PowerShell script checks the given PowerShell script file(s) for validity. .PARAMETER filePattern Specifies the file pattern to the PowerShell file(s) .EXAMPLE @@ -18,13 +18,13 @@ param([string]$filePattern = "") try { if ($filePattern -eq "" ) { $path = Read-Host "Enter the file pattern to the PowerShell file(s)" } - $files = Get-ChildItem $filePattern + + $files = Get-ChildItem -path "$filePattern" -attributes !Directory foreach ($file in $files) { $syntaxError = @() [void][System.Management.Automation.Language.Parser]::ParseFile($file, [ref]$null, [ref]$syntaxError) if ("$syntaxError" -ne "") { throw "$syntaxError" } - $basename = (Get-Item "$file").Basename - "✔️ Valid PowerShell in $basename" + "✔️ Valid PowerShell in $($file.Name)" } exit 0 # success } catch {