@@ -73,48 +73,58 @@ $modules = Get-ChildItem -Path $AnalyzePath -Filter "*.psm1" -Recurse | ForEach-
73
73
}
74
74
}
75
75
76
- Write-Output " Analyzing module files..."
76
+ if ($null -ne $modules ) {
77
+ Write-Output " Analyzing module files..."
77
78
78
- $records = Start-Job - ArgumentList $modules , $SettingsPath {
79
- Param (
80
- $modules ,
81
- $SettingsPath
82
- )
83
- $modules | Invoke-ScriptAnalyzer - Settings $SettingsPath | Select-Object RuleName, ScriptPath, Line, Message
84
- } | Wait-Job | Receive-Job
79
+ $records = Start-Job - ArgumentList $modules , $SettingsPath {
80
+ Param (
81
+ $modules ,
82
+ $SettingsPath
83
+ )
84
+ $modules | Invoke-ScriptAnalyzer - Settings $SettingsPath | Select-Object RuleName, ScriptPath, Line, Message
85
+ } | Wait-Job | Receive-Job
85
86
86
- if (-not ($null -EQ $records )) {
87
- Write-Output " Violations found in Module Files..."
88
- $records | Format-List | Out-String
87
+ if (-not ($null -EQ $records )) {
88
+ Write-Output " Violations found in Module Files..."
89
+ $records | Format-List | Out-String
89
90
90
- Write-Output $OutputPath
91
+ Write-Output $OutputPath
91
92
92
- Write-Output " Writing violations to output file..."
93
- $records | ConvertTo-SARIF - FilePath " $OutputPath \modules.sarif"
93
+ Write-Output " Writing violations to output file..."
94
+ $records | ConvertTo-SARIF - FilePath " $OutputPath \modules.sarif"
95
+ }
96
+ else {
97
+ Write-Output " No rule violations found in Module Files."
98
+ }
94
99
}
95
100
else {
96
- Write-Output " No rule violations found in Module Files. "
101
+ Write-Output " No Module Files to analyze "
97
102
}
98
103
99
- Write-Output " Analyzing script files..."
104
+ if ($null -ne $scripts ) {
105
+ Write-Output " Analyzing script files..."
100
106
101
- $records = Start-Job - ArgumentList $Scripts , $SettingsPath {
102
- Param (
103
- $Scripts ,
104
- $SettingsPath
105
- )
106
- $Scripts | Invoke-ScriptAnalyzer - Settings $SettingsPath | Select-Object RuleName, ScriptPath, Line, Message
107
- } | Wait-Job | Receive-Job
107
+ $records = Start-Job - ArgumentList $Scripts , $SettingsPath {
108
+ Param (
109
+ $Scripts ,
110
+ $SettingsPath
111
+ )
112
+ $Scripts | Invoke-ScriptAnalyzer - Settings $SettingsPath | Select-Object RuleName, ScriptPath, Line, Message
113
+ } | Wait-Job | Receive-Job
108
114
109
- if (-not ($null -EQ $records )) {
110
- Write-Output " Violations found in Script Files..."
111
- $records | Format-List | Out-String
115
+ if (-not ($null -EQ $records )) {
116
+ Write-Output " Violations found in Script Files..."
117
+ $records | Format-List | Out-String
112
118
113
- Write-Output " Writing violations to output file..."
114
- $records | ConvertTo-SARIF - FilePath " $OutputPath \scripts.sarif"
119
+ Write-Output " Writing violations to output file..."
120
+ $records | ConvertTo-SARIF - FilePath " $OutputPath \scripts.sarif"
121
+ }
122
+ else {
123
+ Write-Output " No rule violations found in Script Files."
124
+ }
115
125
}
116
126
else {
117
- Write-Output " No rule violations found in Script Files. "
127
+ Write-Output " No Script Files to analyze "
118
128
}
119
129
120
130
Write-Output " Analyzing complete."
0 commit comments