Title: -ErrorAction Ignore doesn't work for calling advanced functions · Issue #1759 · PowerShell/PowerShell · GitHub
Open Graph Title: -ErrorAction Ignore doesn't work for calling advanced functions · Issue #1759 · PowerShell/PowerShell
X Title: -ErrorAction Ignore doesn't work for calling advanced functions · Issue #1759 · PowerShell/PowerShell
Description: Create a script with the following code: function foo { [CmdletBinding()] param() process { try { Write-Error 'boo' } finally { } } } function bar { foo -ErrorAction Ignore } Dot-source that script to import the function definitions. Cal...
Open Graph Description: Create a script with the following code: function foo { [CmdletBinding()] param() process { try { Write-Error 'boo' } finally { } } } function bar { foo -ErrorAction Ignore } Dot-source that script...
X Description: Create a script with the following code: function foo { [CmdletBinding()] param() process { try { Write-Error 'boo' } finally { } } } function bar { foo -ErrorAction Ignore } Dot-source tha...
Opengraph URL: https://github.com/PowerShell/PowerShell/issues/1759
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"-ErrorAction Ignore doesn't work for calling advanced functions","articleBody":"1. Create a script with the following code:\r\n\r\n```powershell\r\nfunction foo\r\n{\r\n [CmdletBinding()]\r\n param()\r\n\r\nprocess\r\n{\r\n try\r\n {\r\n Write-Error 'boo'\r\n }\r\n finally { }\r\n}\r\n\r\n}\r\n\r\nfunction bar\r\n{\r\n foo -ErrorAction Ignore\r\n}\r\n```\r\n\r\n1. Dot-source that script to import the function definitions.\r\n2. Call the \"bar\" function.\r\n\r\nExpected result:\r\n Nothing (no output; no error--bar is calling foo with \"-ErrorAction Ignore\").\r\n\r\nActual result:\r\n I get an error, and it's not even the one written by foo:\r\n\r\n```\r\nWrite-Error : The value Ignore is not supported for an ActionPreference variable. The provided value should be used only as a value for a preference\r\nparameter, and has been replaced by the default value. For more information, see the Help topic, \"about_Preference_Variables.\"\r\nAt E:\\temp\\ps_ea_ignore_2.ps1:11 char:13\r\n- Write-Error 'boo'\r\n- ~~~~~~~~~~~~~~~~~\r\n - CategoryInfo : NotSpecified: (:) [Write-Error], NotSupportedException\r\n - FullyQualifiedErrorId : System.NotSupportedException,Microsoft.PowerShell.Commands.WriteErrorCommand\r\n```\r\n\r\nDan Thompson:\r\nIn addition to being annoying for straight-up calling advanced functions (you can't use \"-ErrorAction Ignore\" with them), this also hampers meta-programming (you can't do \"\u0026 $someCmd -ErrorAction Ignore\", because you might not know if $someCmd is an advanced function or not).\r\n","author":{"url":"https://github.com/SteveL-MSFT","@type":"Person","name":"SteveL-MSFT"},"datePublished":"2016-08-12T19:44:11.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":17},"url":"https://github.com/1759/PowerShell/issues/1759"}
| 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:1f93b719-daf0-7404-3fbc-6e469f1e7447 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E006:1FC98B:E66473:1337211:6A5B799A |
| html-safe-nonce | f26c31a29eb6563796e900b73a6c4db19720ec4f79f3141065b04d8b0b22c899 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFMDA2OjFGQzk4QjpFNjY0NzM6MTMzNzIxMTo2QTVCNzk5QSIsInZpc2l0b3JfaWQiOiI2ODM1NjE2NDg2ODk3OTczNjU4IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | d0f69fb765e7c27d3d8eddc9c8895db6546d2c9d2acd85bc2f259142d6315780 |
| hovercard-subject-tag | issue:170945012 |
| 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/1759/issue_layout |
| twitter:image | https://opengraph.githubassets.com/644896ad0219ebcdf2bd49b3286b331b9d1126a95f070e0cc254f029955c1c28/PowerShell/PowerShell/issues/1759 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/644896ad0219ebcdf2bd49b3286b331b9d1126a95f070e0cc254f029955c1c28/PowerShell/PowerShell/issues/1759 |
| og:image:alt | Create a script with the following code: function foo { [CmdletBinding()] param() process { try { Write-Error 'boo' } finally { } } } function bar { foo -ErrorAction Ignore } Dot-source that script... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | SteveL-MSFT |
| hostname | github.com |
| expected-hostname | github.com |
| None | 5290d7e14309ad1e76106a9c4237bd1041517e83ea182c8ab756752cb0c6940b |
| 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 | 9c975978430e9ad293956f2bbdaf153b1bd84a99 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width