When the value of the -Settings parameter is set to $_ inside of a foreach-object loop, PSScriptAnalyzer is unable to find the settings file.
Steps to reproduce:
Create a file that violates a rule that is only checked if a particular setting is triggered.
IE:
if ($true)
{
Write-Output 'Something'
}
This code will throw errors if -Settings is set to CodeFormattingStroustrup but not if -Settings it is omitted.
The following command returns warnings.
invoke-scriptanalyzer -path C:\files\ax.ps1 -Settings 'CodeFormattingStroustrup'
But this one does not.
'CodeFormattingStroustrup' | % { invoke-scriptanalyzer -path C:\files\ax.ps1 -Settings $_ }
Using -Verbose on the non-working example shows that PSScriptAnalyzer cannot find a settings file.
This occurs on version 1.15.0 of PSScriptAnalyzer.
Screenshot

When the value of the
-Settingsparameter is set to$_inside of a foreach-object loop, PSScriptAnalyzer is unable to find the settings file.Steps to reproduce:
Create a file that violates a rule that is only checked if a particular setting is triggered.
IE:
This code will throw errors if
-Settingsis set toCodeFormattingStroustrupbut not if-Settingsit is omitted.The following command returns warnings.
invoke-scriptanalyzer -path C:\files\ax.ps1 -Settings 'CodeFormattingStroustrup'But this one does not.
'CodeFormattingStroustrup' | % { invoke-scriptanalyzer -path C:\files\ax.ps1 -Settings $_ }Using
-Verboseon the non-working example shows that PSScriptAnalyzer cannot find a settings file.This occurs on version 1.15.0 of PSScriptAnalyzer.
Screenshot
