Invoke-ScriptAnalyzer: Parameter set cannot be resolved using the specified named parameters. One or more parameters issued cannot; be used together or an insufficient number of parameters were provided.
When both ( -Fixand -ScriptDefinition) parameters, are supplied, I would expect to get a fixed ScriptDefinition back (instead of a [Microsoft.Windows.PowerShell.ScriptAnalyzer.Generic.DiagnosticRecord]).
This way, it would be easier to (pester) test a rule with SuggestedCorrections.
(You might of cause check the SuggestedCorrections property but that will not confirm it has been correctly inserted in the script.)
Besides it will allow to fix scripts by creating a fixed copy rather than make sure that you have a backup of your files when using this parameter.
Summary of the new feature
Currently the
-Fix
parameter is mutual exclusive with the-ScriptDefinition
parameter:Proposed technical implementation details (optional)
When both (
-Fix
and-ScriptDefinition
) parameters, are supplied, I would expect to get a fixedScriptDefinition
back (instead of a[Microsoft.Windows.PowerShell.ScriptAnalyzer.Generic.DiagnosticRecord]
). This way, it would be easier to (pester) test a rule withSuggestedCorrections
. (You might of cause check theSuggestedCorrections
property but that will not confirm it has been correctly inserted in the script.) Besides it will allow to fix scripts by creating a fixed copy rather than make sure that you have a backup of your files when using this parameter.Wishful thinking:
What is the latest version of PSScriptAnalyzer at the point of writing
1.21.0