You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
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.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.psd1CategoryInfo : InvalidOperation: (C:\Program File...ptAnalyzer.psd1:String) [Invoke-ScriptAnalyzer], CmdletInvocationExceptionFullyQualifiedErrorId : RULE_ERROR,Microsoft.Windows.PowerShell.ScriptAnalyzer.Commands.InvokeScriptAnalyzerCommandErrorDetails :InvocationInfo : System.Management.Automation.InvocationInfoScriptStackTrace : at <ScriptBlock>, <No file>: line 1PipelineIterationInfo : {0, 1}MyCommand : Invoke-ScriptAnalyzerBoundParameters : {}UnboundArguments : {}ScriptLineNumber : 1OffsetInLine : 6HistoryId : 7ScriptName :Line : $res=Invoke-ScriptAnalyzer -path 'C:\Program
Files\WindowsPowerShell\Modules\PSScriptAnalyzer\1.16.1\PSScriptAnalyzer.psd1' -ExcludeRule PSUseToExportFieldsInManifestPositionMessage : 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 : FalseMessage : 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.AutomationHResult : -2146233087Exception 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
Repro on a new VM on Azure, template Visual Studio Enterprise 2017 on Windows Server 2016 (x64)
$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
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.
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> rverwriteErrorStream : TruePSMessageDetails :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.BuiltinRulesHResult : -2147467261
Activity
LaurentDardenne commentedon Feb 20, 2018
The exception may also be System.ArgumentOutOfRangeException: The index must be within the limits of the List.
bergmeister commentedon Feb 20, 2018
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
It would also be interesting to see more error details using e.g.
$error[0] | select *LaurentDardenne commentedon Feb 21, 2018
May be is it only on my computer...
No error on Windows Server 2016
On my computer :
LaurentDardenne commentedon Feb 21, 2018
Same error on a VM with Windows server 2016 and VS 2017:
I do not think that the code of the rule is in question.
LaurentDardenne commentedon Feb 21, 2018
Repro on a new VM on Azure, template Visual Studio Enterprise 2017 on Windows Server 2016 (x64)

bergmeister commentedon Feb 21, 2018
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.
LaurentDardenne commentedon Feb 26, 2018
This case may be related (?)
With the development branch :
LaurentDardenne commentedon Feb 26, 2018
With the development branch.
This 'works', but should not:
[STA] C: \ temp\pssaDev\out\PSScriptAnalyzer> Invoke-ScriptAnalyzer -ScriptDefinition 'if ( 0 = 0 ){}' -ExcludeRule psAvoidAssignmentToAutomaticVariable
bergmeister commentedon Mar 30, 2018
Related to #902