-
Notifications
You must be signed in to change notification settings - Fork 395
PSMissingModuleManifestField throw System.IndexOutOfRangeException #901
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
The exception may also be System.ArgumentOutOfRangeException: The index must be within the limits of the List. |
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. |
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 |
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. |
@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 (?) [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 |
With the development branch. This 'works', but should not: |
Related to #902 |
Steps to reproduce
Expected behavior
No error.
Actual behavior
Environment data
See also the issue #900
The text was updated successfully, but these errors were encountered: