Skip to content

This is a test project to test the (`'count' must be non-negative`) PSScriptAnalyzer error.

Notifications You must be signed in to change notification settings

KyleMartin901/km-psscript

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Description

This is a test project to test the ('count' must be non-negative) PSScriptAnalyzer error.

Simulate the error

This error was tested using the following setup

Tool Version
PowerShell 6.0.4
PSScriptAnalyzer 1.17.1

Replicate the error

PowerShell Console

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

Docker

A docker container can be built to be used to run the command and replicated the error

  1. Build container
    docker build -t kylemartin901/km-psscript .
  2. 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'
  3. 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

About

This is a test project to test the (`'count' must be non-negative`) PSScriptAnalyzer error.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published