Skip to content

Commit ff0c8d2

Browse files
author
Markus Fleschutz
committed
Update check-ps1-file.ps1
1 parent 8cf0a23 commit ff0c8d2

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

Scripts/check-ps1-file.ps1

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
.SYNOPSIS
33
Checks PowerShell file(s) for validity
44
.DESCRIPTION
5-
This PowerShell script checks the given PowerShell file(s) for validity.
5+
This PowerShell script checks the given PowerShell script file(s) for validity.
66
.PARAMETER filePattern
77
Specifies the file pattern to the PowerShell file(s)
88
.EXAMPLE
@@ -18,13 +18,13 @@ param([string]$filePattern = "")
1818

1919
try {
2020
if ($filePattern -eq "" ) { $path = Read-Host "Enter the file pattern to the PowerShell file(s)" }
21-
$files = Get-ChildItem $filePattern
21+
22+
$files = Get-ChildItem -path "$filePattern" -attributes !Directory
2223
foreach ($file in $files) {
2324
$syntaxError = @()
2425
[void][System.Management.Automation.Language.Parser]::ParseFile($file, [ref]$null, [ref]$syntaxError)
2526
if ("$syntaxError" -ne "") { throw "$syntaxError" }
26-
$basename = (Get-Item "$file").Basename
27-
"✔️ Valid PowerShell in $basename"
27+
"✔️ Valid PowerShell in $($file.Name)"
2828
}
2929
exit 0 # success
3030
} catch {

0 commit comments

Comments
 (0)