File tree Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Original file line number Diff line number Diff line change 2
2
. SYNOPSIS
3
3
Checks PowerShell file(s) for validity
4
4
. 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.
6
6
. PARAMETER filePattern
7
7
Specifies the file pattern to the PowerShell file(s)
8
8
. EXAMPLE
@@ -18,13 +18,13 @@ param([string]$filePattern = "")
18
18
19
19
try {
20
20
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
22
23
foreach ($file in $files ) {
23
24
$syntaxError = @ ()
24
25
[void ][System.Management.Automation.Language.Parser ]::ParseFile($file , [ref ]$null , [ref ]$syntaxError )
25
26
if (" $syntaxError " -ne " " ) { throw " $syntaxError " }
26
- $basename = (Get-Item " $file " ).Basename
27
- " ✔️ Valid PowerShell in $basename "
27
+ " ✔️ Valid PowerShell in $ ( $file.Name ) "
28
28
}
29
29
exit 0 # success
30
30
} catch {
You can’t perform that action at this time.
0 commit comments