Title: `ErrorRecord.InvocationInfo.Statement` property doesn't report full statement for command syntax / invalid-argument errors · Issue #20638 · PowerShell/PowerShell · GitHub
Open Graph Title: `ErrorRecord.InvocationInfo.Statement` property doesn't report full statement for command syntax / invalid-argument errors · Issue #20638 · PowerShell/PowerShell
X Title: `ErrorRecord.InvocationInfo.Statement` property doesn't report full statement for command syntax / invalid-argument errors · Issue #20638 · PowerShell/PowerShell
Description: Prerequisites Write a descriptive title. Make sure you are able to repro it on the latest released version Search the existing issues. Refer to the FAQ. Refer to Differences between Windows PowerShell 5.1 and PowerShell. Steps to reprodu...
Open Graph Description: Prerequisites Write a descriptive title. Make sure you are able to repro it on the latest released version Search the existing issues. Refer to the FAQ. Refer to Differences between Windows PowerSh...
X Description: Prerequisites Write a descriptive title. Make sure you are able to repro it on the latest released version Search the existing issues. Refer to the FAQ. Refer to Differences between Windows PowerSh...
Opengraph URL: https://github.com/PowerShell/PowerShell/issues/20638
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`ErrorRecord.InvocationInfo.Statement` property doesn't report full statement for command syntax / invalid-argument errors","articleBody":"### Prerequisites\r\n\r\n- [X] Write a descriptive title.\r\n- [X] Make sure you are able to repro it on the [latest released version](https://github.com/PowerShell/PowerShell/releases)\r\n- [X] Search the existing issues.\r\n- [X] Refer to the [FAQ](https://github.com/PowerShell/PowerShell/blob/master/docs/FAQ.md).\r\n- [X] Refer to [Differences between Windows PowerShell 5.1 and PowerShell](https://learn.microsoft.com/powershell/scripting/whats-new/differences-from-windows-powershell).\r\n\r\n### Steps to reproduce\r\n\r\nThe new-in-7.4 `ErrorRecord.InvocationInfo.Statement` property is designed to report the whole statement that triggered the error (possibly spanning multiple lines).\r\n\r\nThis 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):\r\n\r\n```powershell\r\ntry {\r\n Get-Item -NoSuchParameter -LiteralPath .\r\n}\r\ncatch {\r\n '[' + $_.InvocationInfo.Statement + ']'\r\n}\r\n```\r\n\r\n### Expected behavior\r\n\r\n```console\r\n[Get-Item -NoSuchParameter -LiteralPath .]\r\n```\r\n\r\n### Actual behavior\r\n\r\n```console\r\n[-NoSuchParameter]\r\n```\r\nThat is, only the offending parameter is reported.\r\n\r\nThis applies both to unrecognized parameters and known parameters having been given no argument.\r\nIf a known parameter is given an invalid argument, only that argument is reported.\r\n\r\n### Error details\r\n\r\n_No response_\r\n\r\n### Environment data\r\n\r\n```powershell\r\nPowerShell 7.4.0-rc.1\r\n```\r\n\r\n\r\n### Visuals\r\n\r\n_No response_","author":{"url":"https://github.com/mklement0","@type":"Person","name":"mklement0"},"datePublished":"2023-11-06T13:53:27.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/20638/PowerShell/issues/20638"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:1bbe0c6c-3187-4bcc-57cc-f404f878acac |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | DF62:2E90F6:17EC88F:22D17A6:6A54E704 |
| html-safe-nonce | 33b216ecab758206bba423b974e9143b9f9ee7137f2620cb758ed9b7f22fb466 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJERjYyOjJFOTBGNjoxN0VDODhGOjIyRDE3QTY6NkE1NEU3MDQiLCJ2aXNpdG9yX2lkIjoiNTc0Mzc0Nzk3MjQ2ODEwNzAxMiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 6a24eb5c1f5d232ae5220083997a173658a16d5bac820ca8c031916bb56f2367 |
| hovercard-subject-tag | issue:1979214936 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/PowerShell/PowerShell/20638/issue_layout |
| twitter:image | https://opengraph.githubassets.com/36ccc0788ebff7b81d3368ec02b9744007216d0cd189a6df4d23a5ed327a2163/PowerShell/PowerShell/issues/20638 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/36ccc0788ebff7b81d3368ec02b9744007216d0cd189a6df4d23a5ed327a2163/PowerShell/PowerShell/issues/20638 |
| og:image:alt | Prerequisites Write a descriptive title. Make sure you are able to repro it on the latest released version Search the existing issues. Refer to the FAQ. Refer to Differences between Windows PowerSh... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | mklement0 |
| hostname | github.com |
| expected-hostname | github.com |
| None | eae2aab99907699a22d2c8449aa683ca74454fca87211b98f7c7b722086b2839 |
| turbo-cache-control | no-preview |
| go-import | github.com/PowerShell/PowerShell git https://github.com/PowerShell/PowerShell.git |
| octolytics-dimension-user_id | 11524380 |
| octolytics-dimension-user_login | PowerShell |
| octolytics-dimension-repository_id | 49609581 |
| octolytics-dimension-repository_nwo | PowerShell/PowerShell |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 49609581 |
| octolytics-dimension-repository_network_root_nwo | PowerShell/PowerShell |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | bb1b4ffdc07c66de20ad344214f55df0aa364bd3 |
| ui-target | canary-2 |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width