This is a test project to test the ('count' must be non-negative
) PSScriptAnalyzer error.
This error was tested using the following setup
Tool | Version |
---|---|
PowerShell | 6.0.4 |
PSScriptAnalyzer | 1.17.1 |
If you run the following command
Invoke-ScriptAnalyzer -Path Test-Func.ps1 -Settings psscriptanalyzersettings.psd1
It will give the following error
Invoke-ScriptAnalyzer : 'count' must be non-negative.
Parameter name: count
At line:1 char:1
+ Invoke-ScriptAnalyzer -Path Test-Func.ps1 -Settings psscriptanalyzers ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (/Users/kyle/Dev...t/Test-Func.ps1:String) [Invoke-ScriptAnalyzer], ArgumentOutOfRangeException
+ FullyQualifiedErrorId : RULE_ERROR,Microsoft.Windows.PowerShell.ScriptAnalyzer.Commands.InvokeScriptAnalyzerCommand
A docker container can be built to be used to run the command and replicated the error
- Build container
docker build -t kylemartin901/km-psscript .
- Run the container with the Invoke-Script command
docker run -it --rm kylemartin901/km-psscript pwsh -c 'Invoke-ScriptAnalyzer -Path Test-Func.ps1 -Settings psscriptanalyzersettings.psd1'
- Output
Invoke-ScriptAnalyzer : 'count' must be non-negative. Parameter name: count At line:1 char:1 + Invoke-ScriptAnalyzer -Path Test-Func.ps1 -Settings psscriptanalyzers ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (/temp/scripts/Test-Func.ps1:String)[Invoke-ScriptAnalyzer], ArgumentOutOfRangeException + FullyQualifiedErrorId : RULE_ERROR,Microsoft.Windows.PowerShell.ScriptAnalyzer.Commands.InvokeScriptAnalyzerCommand