Title: Invoke-RestMethod parameter combination of OutFile/PassThru does not write to file as intended · Issue #15409 · PowerShell/PowerShell · GitHub
Open Graph Title: Invoke-RestMethod parameter combination of OutFile/PassThru does not write to file as intended · Issue #15409 · PowerShell/PowerShell
X Title: Invoke-RestMethod parameter combination of OutFile/PassThru does not write to file as intended · Issue #15409 · PowerShell/PowerShell
Description: Problem description In Invoke-RestMethod, the PassThru parameter must be used with the OutFile parameter. The intent is that you can write the results to the file and get the output to the pipeline. But the cmdlets only write to the pipe...
Open Graph Description: Problem description In Invoke-RestMethod, the PassThru parameter must be used with the OutFile parameter. The intent is that you can write the results to the file and get the output to the pipeline...
X Description: Problem description In Invoke-RestMethod, the PassThru parameter must be used with the OutFile parameter. The intent is that you can write the results to the file and get the output to the pipeline...
Opengraph URL: https://github.com/PowerShell/PowerShell/issues/15409
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Invoke-RestMethod parameter combination of OutFile/PassThru does not write to file as intended","articleBody":"## Problem description\r\n\r\nIn `Invoke-RestMethod`, the **PassThru** parameter must be used with the **OutFile** parameter. The intent is that you can write the results to the file and get the output to the pipeline. But the cmdlets only write to the pipeline, not the file.\r\n\r\nThe problem code starts here:\r\n\r\nhttps://github.com/PowerShell/PowerShell/blob/38d582f038f31acfc1a748d60a5331eb82a3bd28/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/InvokeRestMethodCommand.Common.cs#L387\r\n\r\n```csharp\r\nif (ShouldWriteToPipeline)\r\n{\r\n ...\r\n}\r\nelse if (ShouldSaveToOutFile)\r\n{\r\n ...\r\n}\r\n```\r\n\r\nNotice that the logic outputs pipeline and skips the output to the file. Both `ShouldWriteToPipeline` and `ShouldSaveToOutFile` can be true so need to remove the `else`.\r\n\r\n## Steps to reproduce\r\n\r\n```powershell\r\nInvoke-RestMethod https://taxonomyservice.azurefd.net/taxonomies/product-uri -PassThru -OutFile C:\\temp\\irm.json\r\n```\r\n\r\n## Expected behavior\r\n\r\nOutput to console and to the file.\r\n\r\n## Actual behavior\r\n\r\nOutput to console only. The output file is not created.\r\n\r\n## Environment data\r\n\r\nThis affects all versions 5.1 and higher.\r\n\r\n","author":{"url":"https://github.com/sdwheeler","@type":"Person","name":"sdwheeler"},"datePublished":"2021-05-14T21:53:35.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":20},"url":"https://github.com/15409/PowerShell/issues/15409"}
| 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:8ce5cda6-8d59-7bff-fbf1-9617c9279d02 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D93E:67ABE:BCBBF5:10DDCE6:6A59F8B1 |
| html-safe-nonce | a0fe4c06b743a2b00be5cb91f724b91a5ec4580c81ed844f75499436f1303eb0 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEOTNFOjY3QUJFOkJDQkJGNToxMEREQ0U2OjZBNTlGOEIxIiwidmlzaXRvcl9pZCI6IjE2MjYxOTkwNzUzMTcyMTc0NTciLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 2e48d030fff322fe6551686b8b2c3eb086c2772ec08156cd7601b08a17f2e255 |
| hovercard-subject-tag | issue:892270648 |
| 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/15409/issue_layout |
| twitter:image | https://opengraph.githubassets.com/f9e5c3e7cbe4839e132429ced1316b308b3630f093e48518ddff4a3688cda109/PowerShell/PowerShell/issues/15409 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/f9e5c3e7cbe4839e132429ced1316b308b3630f093e48518ddff4a3688cda109/PowerShell/PowerShell/issues/15409 |
| og:image:alt | Problem description In Invoke-RestMethod, the PassThru parameter must be used with the OutFile parameter. The intent is that you can write the results to the file and get the output to the pipeline... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | sdwheeler |
| hostname | github.com |
| expected-hostname | github.com |
| None | ba3976babb66479b1c943a8edc0777d96157da48fadc0161f9ddb219deee8353 |
| 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 | 24801cf86623a319252348d1fd69122ad974b842 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width