Prerequisites
Steps to reproduce
The new-in-7.4 ErrorRecord.InvocationInfo.Statement property is designed to report the whole statement that triggered the error (possibly spanning multiple lines).
This doesn't work when the error was triggered by a command syntax error or by a parameter having been passed an invalid argument (in other words: the problem seems related to the parameter binder reporting the error):
try {
Get-Item -NoSuchParameter -LiteralPath .
}
catch {
'[' + $_.InvocationInfo.Statement + ']'
}
Expected behavior
[Get-Item -NoSuchParameter -LiteralPath .]
Actual behavior
That is, only the offending parameter is reported.
This applies both to unrecognized parameters and known parameters having been given no argument.
If a known parameter is given an invalid argument, only that argument is reported.
Error details
No response
Environment data
Visuals
No response
Prerequisites
Steps to reproduce
The new-in-7.4
ErrorRecord.InvocationInfo.Statementproperty is designed to report the whole statement that triggered the error (possibly spanning multiple lines).This doesn't work when the error was triggered by a command syntax error or by a parameter having been passed an invalid argument (in other words: the problem seems related to the parameter binder reporting the error):
Expected behavior
[Get-Item -NoSuchParameter -LiteralPath .]Actual behavior
[-NoSuchParameter]That is, only the offending parameter is reported.
This applies both to unrecognized parameters and known parameters having been given no argument.
If a known parameter is given an invalid argument, only that argument is reported.
Error details
No response
Environment data
Visuals
No response