Skip to content

Invoke-ScriptAnalyzer does not report a parse failure in a param() block caused by a missing parameter separator comma. #2192

Description

@FabrizioMarana

Steps to reproduce

param (
    [string[]]$aszServers = @()
    [string]$fServerListFile = ""
)

Expected behaviour

Invoke-ScriptAnalyzer should report a parser-related error because the parameter list is malformed (missing comma between parameters).

Actual behaviour

PowerShell detects the syntax error:

> .\Broken.ps1

At line:2 char:29
+     [string[]]$aszServers = @()
+                             ~
Missing ')' in function parameter list.

However:

> Invoke-ScriptAnalyzer .\Broken.ps1 -Severity Error

returns nothing.

Environment data

$PSVersionTable
Name                           Value
----                           -----
PSVersion                      5.1.26100.8655
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.26100.8655
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1


PSScriptAnalyzer: 1.25.0

Activity

  1. changed the title [-]Invoke-ScriptAnalyzer does not report a parse failure for a script containing a malformed param() block caused by a missing parameter separator comma.[/-] [+]Invoke-ScriptAnalyzer does not report a parse failure in a param() block caused by a missing parameter separator comma.[/+] on Jul 17, 2026
  2. liamjpeters commented on Jul 20, 2026

    @liamjpeters
    Contributor

    👋 Fabby (@FabrizioMarana),

    This is expected. There are actually 4 severities. Information, Warning, Error, ParseError.

    Invoke-ScriptAnalyzer .\Broken.ps1 -Severity Error

    Your example asks only for the Error severity diagnostics. Either omit it, or ask for the ParseError severity diagnostics.

    Invoke-ScriptAnalyzer .\Broken.ps1 -Severity ParseError
    RuleName                            Severity     ScriptName Line  Message
    --------                            --------     ---------- ----  -------
    MissingEndParenthesisInFunctionPara ParseError   Broken.ps1 2     Missing ')' in function parameter list.
    meterList
    UnexpectedToken                     ParseError   Broken.ps1 4     Unexpected token ')' in expression or statement.
    

    Hope that helps!

  3. FabrizioMarana commented on Jul 20, 2026

    @FabrizioMarana
    Author

    Huh! I'm an idiot! I never knew! 😁 Thank you very much!!! Please close issue!

    P.S. On my version: get-help Invoke-ScriptAnalyzer -parameter Severity gives:

    -Severity <String[]>
        After running Script Analyzer with all rules, this parameter selects rule violations with the specified severity.
        Valid values are:
        - Error
        - Warning
        - Information.
    
        You can specify one ore more severity values.
    

    but ParseError does work!!! 🎉

  4. liamjpeters commented on Jul 20, 2026

    @liamjpeters
    Contributor

    Thanks for flagging the docs issue 🙂! I've raised a PR to get that fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions