Skip to content

PSMissingModuleManifestField throw System.IndexOutOfRangeException #901

Description

Steps to reproduce

$res=Invoke-ScriptAnalyzer -path 'C:\Program Files\WindowsPowerShell\Modules\PSScriptAnalyzer\1.16.1\PSScriptAnalyzer.psd1' -ExcludeRule PSUseToExportFieldsInManifest

Expected behavior

No error.

Actual behavior

Invoke-ScriptAnalyzer : L'index se trouve en dehors des limites du tableau.
At line:1 char:6
+ $res=Invoke-ScriptAnalyzer -path 'C:\Program Files\WindowsPowerShell\ ...
+      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (C:\Program File...ptAnalyzer.psd1:String) [Invoke-ScriptAnalyzer], Cm
   dletInvocationException
    + FullyQualifiedErrorId : RULE_ERROR,Microsoft.Windows.PowerShell.ScriptAnalyzer.Commands.InvokeScriptAnalyzerComm
   and

Environment data

$psversiontable
Name                           Value
----                           -----
PSVersion                      5.1.14409.1012
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0, 5.0, 5.1.14409.1012}
BuildVersion                   10.0.14409.1012
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1


 (Get-Module -ListAvailable PSScriptAnalyzer).Version | ForEach-Object { $_.ToString() }
1.16.1
1.16.0
1.15.0
1.12.0
1.11.1

See also the issue #900

Activity

  1. LaurentDardenne commented on Feb 20, 2018

    @LaurentDardenne
    Author

    The exception may also be System.ArgumentOutOfRangeException: The index must be within the limits of the List.

  2. bergmeister commented on Feb 20, 2018

    @bergmeister
    Collaborator

    Does not repro for me and my system seems to be similar to yours (except that my OS is English, it could also be an issue due to the locale). Can you try to see if uninstalling the old versions of PSSA fixes it? If you are interest

    > $PSVersionTable
    Name                           Value
    ----                           -----
    PSVersion                      5.1.16299.248
    PSEdition                      Desktop
    PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
    BuildVersion                   10.0.16299.248
    CLRVersion                     4.0.30319.42000
    WSManStackVersion              3.0
    PSRemotingProtocolVersion      2.3
    SerializationVersion           1.1.0.1
    
    >  (Get-Module -ListAvailable PSScriptAnalyzer).Version | ForEach-Object { $_.ToString() }
    1.16.1

    It would also be interesting to see more error details using e.g. $error[0] | select *

  3. LaurentDardenne commented on Feb 21, 2018

    @LaurentDardenne
    Author

    May be is it only on my computer...

    No error on Windows Server 2016

    $psversiontable
    
    Name                           Value
    ----                           -----
    PSVersion                      5.1.14393.1944
    PSEdition                      Desktop
    PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
    BuildVersion                   10.0.14393.1944
    CLRVersion                     4.0.30319.42000
    WSManStackVersion              3.0
    PSRemotingProtocolVersion      2.3
    SerializationVersion           1.1.0.1
    
    # Microsoft Windows [Version 10.0.14393]

    On my computer :

    #remove all versions:
     install-module psscriptanalyzer
    ipmo psscriptanalyzer
    $res=Invoke-ScriptAnalyzer -path 'C:\Program Files\WindowsPowerShell\Modules\PSScriptAnalyzer\1.16.1\PSScriptAnalyzer.psd1' -ExcludeRule PSUseToExportFieldsInManifest
    $res=Invoke-ScriptAnalyzer -path 'C:\Program Files\WindowsPowerShell\Modules\PSScriptAnalyzer\1.16.1\PSScriptAnalyzer.psd1' -ExcludeRule PSUseToExportFieldsInManifest
    $res=Invoke-ScriptAnalyzer -path 'C:\Program Files\WindowsPowerShell\Modules\PSScriptAnalyzer\1.16.1\PSScriptAnalyzer.psd1' -ExcludeRule PSUseToExportFieldsInManifest
    $res=Invoke-ScriptAnalyzer -path 'C:\Program Files\WindowsPowerShell\Modules\PSScriptAnalyzer\1.16.1\PSScriptAnalyzer.psd1' -ExcludeRule PSUseToExportFieldsInManifest
    $res=Invoke-ScriptAnalyzer -path 'C:\Program Files\WindowsPowerShell\Modules\PSScriptAnalyzer\1.16.1\PSScriptAnalyzer.psd1' -ExcludeRule PSUseToExportFieldsInManifest
    
    Invoke-ScriptAnalyzer : L'index se trouve en dehors des limites du tableau.
    At line:1 char:6
    + $res=Invoke-ScriptAnalyzer -path 'C:\Program Files\WindowsPowerShell\ ...
    +      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : InvalidOperation: (C:\Program File...ptAnalyzer.psd1:String) [Invoke-ScriptAnalyzer], Cm
       dletInvocationException
        + FullyQualifiedErrorId : RULE_ERROR,Microsoft.Windows.PowerShell.ScriptAnalyzer.Commands.InvokeScriptAnalyzerComm
       and
    
    
    Resolve-Error
    
    writeErrorStream      : True
    PSMessageDetails      :
    Exception             : System.Management.Automation.CmdletInvocationException: L'index se trouve en dehors des
                            limites du tableau. ---> System.IndexOutOfRangeException: L'index se trouve en dehors des
                            limites du tableau.
                               à System.Collections.Generic.List`1.Add(T item)
                               à Microsoft.PowerShell.Commands.ModuleCmdletBase.LoadModuleManifest(String
                            moduleManifestPath, ExternalScriptInfo scriptInfo, Hashtable data, Hashtable localizedData,
                            ManifestProcessingFlags manifestProcessingFlags, Version minimumVersion, Version
                            maximumVersion, Version requiredVersion, Nullable`1 requiredModuleGuid, ImportModuleOptions&
                            options, Boolean& containedErrors)
                               à Microsoft.PowerShell.Commands.TestModuleManifestCommand.ProcessRecord()
                               à System.Management.Automation.CommandProcessor.ProcessRecord()
                               --- Fin de la trace de la pile d'exception interne ---
                               à System.Management.Automation.Runspaces.PipelineBase.Invoke(IEnumerable input)
                               à System.Management.Automation.PowerShell.Worker.ConstructPipelineAndDoWork(Runspace rs,
                            Boolean performSyncInvoke)
                               à System.Management.Automation.PowerShell.Worker.CreateRunspaceIfNeededAndDoWork(Runspace
                            rsToUse, Boolean isSync)
                               à
                            System.Management.Automation.PowerShell.CoreInvokeHelper[TInput,TOutput](PSDataCollection`1
                            input, PSDataCollection`1 output, PSInvocationSettings settings)
                               à System.Management.Automation.PowerShell.CoreInvoke[TInput,TOutput](PSDataCollection`1
                            input, PSDataCollection`1 output, PSInvocationSettings settings)
                               à System.Management.Automation.PowerShell.Invoke(IEnumerable input, PSInvocationSettings
                            settings)
                               à Microsoft.Windows.PowerShell.ScriptAnalyzer.Helper.GetModuleManifest(String filePath,
                            IEnumerable`1& errorRecord)
                               à Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules.MissingModuleManifestField.<Analy
                            zeScript>d__0.MoveNext()
                               à System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
                               à System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
                               à Microsoft.Windows.PowerShell.ScriptAnalyzer.ScriptAnalyzer.<>c__DisplayClass78_0.<AnalyzeS
                            yntaxTree>b__1()
    TargetObject          : C:\Program Files\WindowsPowerShell\Modules\PSScriptAnalyzer\1.16.1\PSScriptAnalyzer.psd1
    CategoryInfo          : InvalidOperation: (C:\Program File...ptAnalyzer.psd1:String) [Invoke-ScriptAnalyzer],
                            CmdletInvocationException
    FullyQualifiedErrorId : RULE_ERROR,Microsoft.Windows.PowerShell.ScriptAnalyzer.Commands.InvokeScriptAnalyzerCommand
    ErrorDetails          :
    InvocationInfo        : System.Management.Automation.InvocationInfo
    ScriptStackTrace      : at <ScriptBlock>, <No file>: line 1
    PipelineIterationInfo : {0, 1}
    
    MyCommand             : Invoke-ScriptAnalyzer
    BoundParameters       : {}
    UnboundArguments      : {}
    ScriptLineNumber      : 1
    OffsetInLine          : 6
    HistoryId             : 7
    ScriptName            :
    Line                  : $res=Invoke-ScriptAnalyzer -path 'C:\Program
                            Files\WindowsPowerShell\Modules\PSScriptAnalyzer\1.16.1\PSScriptAnalyzer.psd1' -ExcludeRule
                            PSUseToExportFieldsInManifest
    PositionMessage       : At line:1 char:6
                            + $res=Invoke-ScriptAnalyzer -path 'C:\Program Files\WindowsPowerShell\ ...
                            +      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    PSScriptRoot          :
    PSCommandPath         :
    InvocationName        : Invoke-ScriptAnalyzer
    PipelineLength        : 0
    PipelinePosition      : 0
    ExpectingInput        : False
    CommandOrigin         : Internal
    DisplayScriptPosition :
    
    Exception at nesting level 0 ---------------------------------------------------
    
    ErrorRecord                 : L'index se trouve en dehors des limites du tableau.
    WasThrownFromThrowStatement : False
    Message                     : L'index se trouve en dehors des limites du tableau.
    Data                        : {}
    InnerException              : System.IndexOutOfRangeException: L'index se trouve en dehors des limites du tableau.
                                     à System.Collections.Generic.List`1.Add(T item)
                                     à Microsoft.PowerShell.Commands.ModuleCmdletBase.LoadModuleManifest(String
                                  moduleManifestPath, ExternalScriptInfo scriptInfo, Hashtable data, Hashtable
                                  localizedData, ManifestProcessingFlags manifestProcessingFlags, Version minimumVersion,
                                  Version maximumVersion, Version requiredVersion, Nullable`1 requiredModuleGuid,
                                  ImportModuleOptions& options, Boolean& containedErrors)
                                     à Microsoft.PowerShell.Commands.TestModuleManifestCommand.ProcessRecord()
                                     à System.Management.Automation.CommandProcessor.ProcessRecord()
    TargetSite                  : System.Collections.ObjectModel.Collection`1[System.Management.Automation.PSObject]
                                  Invoke(System.Collections.IEnumerable)
    StackTrace                  :    à System.Management.Automation.Runspaces.PipelineBase.Invoke(IEnumerable input)
                                     à System.Management.Automation.PowerShell.Worker.ConstructPipelineAndDoWork(Runspace
                                  rs, Boolean performSyncInvoke)
                                     à
                                  System.Management.Automation.PowerShell.Worker.CreateRunspaceIfNeededAndDoWork(Runspace
                                  rsToUse, Boolean isSync)
                                     à System.Management.Automation.PowerShell.CoreInvokeHelper[TInput,TOutput](PSDataColle
                                  ction`1 input, PSDataCollection`1 output, PSInvocationSettings settings)
                                     à
                                  System.Management.Automation.PowerShell.CoreInvoke[TInput,TOutput](PSDataCollection`1
                                  input, PSDataCollection`1 output, PSInvocationSettings settings)
                                     à System.Management.Automation.PowerShell.Invoke(IEnumerable input,
                                  PSInvocationSettings settings)
                                     à Microsoft.Windows.PowerShell.ScriptAnalyzer.Helper.GetModuleManifest(String
                                  filePath, IEnumerable`1& errorRecord)
                                     à Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules.MissingModuleManifestField.
                                  <AnalyzeScript>d__0.MoveNext()
                                     à System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
                                     à System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
                                     à Microsoft.Windows.PowerShell.ScriptAnalyzer.ScriptAnalyzer.<>c__DisplayClass78_0.<An
                                  alyzeSyntaxTree>b__1()
    HelpLink                    :
    Source                      : System.Management.Automation
    HResult                     : -2146233087
    
    Exception at nesting level 1 ---------------------------------------------------
    
    Message        : L'index se trouve en dehors des limites du tableau.
    Data           : {}
    InnerException :
    TargetSite     : Void Add(T)
    StackTrace     :    à System.Collections.Generic.List`1.Add(T item)
                        à Microsoft.PowerShell.Commands.ModuleCmdletBase.LoadModuleManifest(String moduleManifestPath,
                     ExternalScriptInfo scriptInfo, Hashtable data, Hashtable localizedData, ManifestProcessingFlags
                     manifestProcessingFlags, Version minimumVersion, Version maximumVersion, Version requiredVersion,
                     Nullable`1 requiredModuleGuid, ImportModuleOptions& options, Boolean& containedErrors)
                        à Microsoft.PowerShell.Commands.TestModuleManifestCommand.ProcessRecord()
                        à System.Management.Automation.CommandProcessor.ProcessRecord()
    HelpLink       :
    Source         : mscorlib
    HResult        : -2146233080
  4. LaurentDardenne commented on Feb 21, 2018

    @LaurentDardenne
    Author

    Same error on a VM with Windows server 2016 and VS 2017:

    PS C:\Users\laurent> $e.exception.innerexception|select *
    
    
    Message        : Collection was modified; enumeration operation may not execute.
    Data           : {}
    InnerException :
    TargetSite     : Void ThrowInvalidOperationException(System.ExceptionResource)
    StackTrace     :    at System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource)
                        at System.Collections.Generic.List`1.Enumerator.MoveNextRare()
                        at Microsoft.PowerShell.Commands.ModuleCmdletBase.UpdateCommandCollection(Collection`1 list,
                     List`1 patterns)
                        at Microsoft.PowerShell.Commands.ModuleCmdletBase.LoadModuleManifest(String moduleManifestPath,
                     ExternalScriptInfo manifestScriptInfo, Hashtable data, Hashtable localizedData,
                     ManifestProcessingFlags manifestProcessingFlags, Version minimumVersion, Version maximumVersion,
                     Version requiredVersion, Nullable`1 requiredModuleGuid, ImportModuleOptions& options, Boolean&
                     containedErrors)
                        at Microsoft.PowerShell.Commands.TestModuleManifestCommand.ProcessRecord()
                        at System.Management.Automation.CommandProcessor.ProcessRecord()
    HelpLink       :
    Source         : mscorlib
    HResult        : -2146233079
    
    
    
    PS C:\Users\laurent> $PSVersionTable
    
    Name                           Value
    ----                           -----
    PSVersion                      5.1.14393.1944
    PSEdition                      Desktop
    PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
    BuildVersion                   10.0.14393.1944
    CLRVersion                     4.0.30319.42000
    WSManStackVersion              3.0
    PSRemotingProtocolVersion      2.3
    SerializationVersion           1.1.0.1
    
    
    PS C:\Users\laurent> cmd.exe /k ver
    
    Microsoft Windows [Version 10.0.14393]

    I do not think that the code of the rule is in question.

  5. LaurentDardenne commented on Feb 21, 2018

    @LaurentDardenne
    Author

    Repro on a new VM on Azure, template Visual Studio Enterprise 2017 on Windows Server 2016 (x64)
    image

    $PSVersionTable
    
    Name                           Value
    ----                           -----
    PSVersion                      5.1.14393.1944
    PSEdition                      Desktop
    PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
    BuildVersion                   10.0.14393.1944
    CLRVersion                     4.0.30319.42000
    WSManStackVersion              3.0
    PSRemotingProtocolVersion      2.3
    SerializationVersion           1.1.0.1
    PS C:\Users\Laurent> $e=$error[0]
    PS C:\Users\Laurent> $e.Exception|select *
    
    
    ErrorRecord                 : Index was outside the bounds of the array.
    WasThrownFromThrowStatement : False
    Message                     : Index was outside the bounds of the array.
    Data                        : {}
    InnerException              : System.IndexOutOfRangeException: Index was outside the bounds of the array.
                                     at System.Collections.Generic.List`1.Add(T item)
                                     at Microsoft.PowerShell.Commands.ModuleCmdletBase.LoadModuleManifest(String
                                  moduleManifestPath, ExternalScriptInfo manifestScriptInfo, Hashtable data, Hashtable
                                  localizedData, ManifestProcessingFlags manifestProcessingFlags, Version minimumVersion,
                                  Version maximumVersion, Version requiredVersion, Nullable`1 requiredModuleGuid,
                                  ImportModuleOptions& options, Boolean& containedErrors)
                                     at Microsoft.PowerShell.Commands.TestModuleManifestCommand.ProcessRecord()
                                     at System.Management.Automation.CommandProcessor.ProcessRecord()
    TargetSite                  : System.Collections.ObjectModel.Collection`1[System.Management.Automation.PSObject]
                                  Invoke(System.Collections.IEnumerable)
    StackTrace                  :    at System.Management.Automation.Runspaces.PipelineBase.Invoke(IEnumerable input)
                                     at System.Management.Automation.PowerShell.Worker.ConstructPipelineAndDoWork(Runspace
                                  rs, Boolean performSyncInvoke)
                                     at
                                  System.Management.Automation.PowerShell.Worker.CreateRunspaceIfNeededAndDoWork(Runspace
                                  rsToUse, Boolean isSync)
                                     at System.Management.Automation.PowerShell.CoreInvokeHelper[TInput,TOutput](PSDataColl
                                  ection`1 input, PSDataCollection`1 output, PSInvocationSettings settings)
                                     at
                                  System.Management.Automation.PowerShell.CoreInvoke[TInput,TOutput](PSDataCollection`1
                                  input, PSDataCollection`1 output, PSInvocationSettings settings)
                                     at System.Management.Automation.PowerShell.Invoke(IEnumerable input,
                                  PSInvocationSettings settings)
                                     at Microsoft.Windows.PowerShell.ScriptAnalyzer.Helper.GetModuleManifest(String
                                  filePath, IEnumerable`1& errorRecord)
                                     at Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules.MissingModuleManifestField
                                  .<AnalyzeScript>d__0.MoveNext()
                                     at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
                                     at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
                                     at Microsoft.Windows.PowerShell.ScriptAnalyzer.ScriptAnalyzer.<>c__DisplayClass78_0.<A
                                  nalyzeSyntaxTree>b__1()
    HelpLink                    :
    Source                      : System.Management.Automation
    HResult                     : -2146233087
    
    
    
    PS C:\Users\Laurent> $e.Exception.InnerException|select *
    
    
    Message        : Index was outside the bounds of the array.
    Data           : {}
    InnerException :
    TargetSite     : Void Add(T)
    StackTrace     :    at System.Collections.Generic.List`1.Add(T item)
                        at Microsoft.PowerShell.Commands.ModuleCmdletBase.LoadModuleManifest(String moduleManifestPath,
                     ExternalScriptInfo manifestScriptInfo, Hashtable data, Hashtable localizedData,
                     ManifestProcessingFlags manifestProcessingFlags, Version minimumVersion, Version maximumVersion,
                     Version requiredVersion, Nullable`1 requiredModuleGuid, ImportModuleOptions& options, Boolean&
                     containedErrors)
                        at Microsoft.PowerShell.Commands.TestModuleManifestCommand.ProcessRecord()
                        at System.Management.Automation.CommandProcessor.ProcessRecord()
    HelpLink       :
    Source         : mscorlib
    HResult        : -2146233080
  6. bergmeister commented on Feb 21, 2018

    @bergmeister
    Collaborator

    Laurent Dardenne (@LaurentDardenne) Interesting findings, thanks for the report. I like your idea of using an Azure VM, which is something that is a relatively standardised and well known environment. I will try to see if I can reproduce it next week on a new Azure VM using your referenced template as well.

  7. LaurentDardenne commented on Feb 26, 2018

    @LaurentDardenne
    Author

    This case may be related (?)
    With the development branch :

    [STA] C:\temp\pssaDev\out\PSScriptAnalyzer> Invoke-ScriptAnalyzer -ScriptDefinition 'if ( 0 = 0 ){}' -ExcludeRule PSPossibleIncorrectUsageOfAssignmentOperator
    
    Invoke-ScriptAnalyzer : Parse error in script definition:  The assignment expression is not valid. The input to an
    assignment operator must be an object that is able to accept assignments, such as a variable or a property at line 1
    column 6.
    At line:1 char:1
    + Invoke-ScriptAnalyzer -ScriptDefinition 'if ( 0 = 0 ){}' -ExcludeRule ...
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : ParserError: (InvalidLeftHandSide:String) [Invoke-ScriptAnalyzer], ParseException
        + FullyQualifiedErrorId : Parse error in script definition:  The assignment expression is not valid. The input to
       an assignment operator must be an object that is able to accept assignments, such as a variable or a property at l
      ine 1 column 6.,Microsoft.Windows.PowerShell.ScriptAnalyzer.Commands.InvokeScriptAnalyzerCommand
    
    Invoke-ScriptAnalyzer : La référence d'objet n'est pas définie à une instance d'un objet.
    At line:1 char:1
    + Invoke-ScriptAnalyzer -ScriptDefinition 'if ( 0 = 0 ){}' -ExcludeRule ...
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : InvalidOperation: (:) [Invoke-ScriptAnalyzer], NullReferenceException
        + FullyQualifiedErrorId : RULE_ERROR,Microsoft.Windows.PowerShell.ScriptAnalyzer.Commands.InvokeScriptAnalyzerComm
       and
    
    [STA] C:\temp\pssaDev\out\PSScriptAnalyzer> rver
    
    writeErrorStream      : True
    PSMessageDetails      :
    Exception             : System.NullReferenceException: La référence d'objet n'est pas définie à une instance d'un
                            objet.
                               à Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules.AvoidAssignmentToAutomaticVariabl
                            e.<AnalyzeScript>d__1.MoveNext()
                               à System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
                               à System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
                               à Microsoft.Windows.PowerShell.ScriptAnalyzer.ScriptAnalyzer.<>c__DisplayClass81_1.<AnalyzeS
                            yntaxTree>b__2()
    TargetObject          :
    CategoryInfo          : InvalidOperation: (:) [Invoke-ScriptAnalyzer], NullReferenceException
    FullyQualifiedErrorId : RULE_ERROR,Microsoft.Windows.PowerShell.ScriptAnalyzer.Commands.InvokeScriptAnalyzerCommand
    ErrorDetails          :
    InvocationInfo        : System.Management.Automation.InvocationInfo
    ScriptStackTrace      : at <ScriptBlock>, <No file>: line 1
    PipelineIterationInfo : {0, 1}
    
    MyCommand             : Invoke-ScriptAnalyzer
    BoundParameters       : {}
    UnboundArguments      : {}
    ScriptLineNumber      : 1
    OffsetInLine          : 1
    HistoryId             : 7
    ScriptName            :
    Line                  : Invoke-ScriptAnalyzer -ScriptDefinition 'if ( 0 = 0 ){}' -ExcludeRule
                            PSPossibleIncorrectUsageOfAssignmentOperator
    PositionMessage       : At line:1 char:1
                            + Invoke-ScriptAnalyzer -ScriptDefinition 'if ( 0 = 0 ){}' -ExcludeRule ...
                            + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    PSScriptRoot          :
    PSCommandPath         :
    InvocationName        : Invoke-ScriptAnalyzer
    PipelineLength        : 0
    PipelinePosition      : 0
    ExpectingInput        : False
    CommandOrigin         : Internal
    DisplayScriptPosition :
    
    Exception at nesting level 0 ---------------------------------------------------
    
    Message        : La référence d'objet n'est pas définie à une instance d'un objet.
    Data           : {}
    InnerException :
    TargetSite     : Boolean MoveNext()
    StackTrace     :    à Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules.AvoidAssignmentToAutomaticVariable.<Anal
                     yzeScript>d__1.MoveNext()
                        à System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
                        à System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
                        à Microsoft.Windows.PowerShell.ScriptAnalyzer.ScriptAnalyzer.<>c__DisplayClass81_1.<AnalyzeSyntaxTr
                     ee>b__2()
    HelpLink       :
    Source         : Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules
    HResult        : -2147467261
  8. LaurentDardenne commented on Feb 26, 2018

    @LaurentDardenne
    Author

    With the development branch.

    This 'works', but should not:
    [STA] C: \ temp\pssaDev\out\PSScriptAnalyzer> Invoke-ScriptAnalyzer -ScriptDefinition 'if ( 0 = 0 ){}' -ExcludeRule psAvoidAssignmentToAutomaticVariable

  9. bergmeister commented on Mar 30, 2018

    @bergmeister
    Collaborator

    Related to #902

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions