Title: Invoke-WebRequest / Invoke-RestMethod -Verbose shows only the directory (folder) name when a directory path is passed to `-OutFile` · Issue #21081 · PowerShell/PowerShell · GitHub
Open Graph Title: Invoke-WebRequest / Invoke-RestMethod -Verbose shows only the directory (folder) name when a directory path is passed to `-OutFile` · Issue #21081 · PowerShell/PowerShell
X Title: Invoke-WebRequest / Invoke-RestMethod -Verbose shows only the directory (folder) name when a directory path is passed to `-OutFile` · Issue #21081 · 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/21081
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Invoke-WebRequest / Invoke-RestMethod -Verbose shows only the directory (folder) name when a directory path is passed to `-OutFile`","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\nThanks to a contribution by @CarloToso, since v7.4.0 it has been possible to pass a _directory_ rather than a file path to `-OutFile`, in which the web cmdlets use the (ultimate) target URL's _last segment_ as the file name.\r\n\r\nGiven that, when redirections are involved, you won't know what that last segment is, using `-Verbose` is an important way to discover the effective output file name.\r\n\r\nUnfortunately, `-Verbose` currently misreports the _directory_'s name as the output file name:\r\n\r\n\r\n```powershell\r\n# This downloads to file /tmp/ascii_to_unicode.bat\r\nInvoke-WebRequest -Verbose -OutFile /tmp https://filesamples.com/samples/code/bat/ascii_to_unicode.bat\r\n\r\n# Clean up\r\nRemove-Item /tmp/ascii_to_unicode.bat\r\n```\r\n\r\n### Expected behavior\r\n\r\n```console\r\nVERBOSE: Requested HTTP/1.1 GET with 0-byte payload\r\nVERBOSE: Received HTTP/1.1 response of content type application/octet-stream of unknown size\r\nVERBOSE: File Name: ascii_to_unicode.bat\r\n```\r\n\r\n\r\n### Actual behavior\r\n\r\n```console\r\nVERBOSE: Requested HTTP/1.1 GET with 0-byte payload\r\nVERBOSE: Received HTTP/1.1 response of content type application/octet-stream of unknown size\r\nVERBOSE: File Name: tmp\r\n```\r\n\r\nThat is, the *directory*'s name is reported.\r\n\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":"2024-01-16T19:25:53.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/21081/PowerShell/issues/21081"}
| 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:a66e052f-56d9-257c-aa2e-e06b773552a1 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D966:1F919D:E17AB1:143F1CE:6A5A0B01 |
| html-safe-nonce | 674fc6d4e3e326679f36db35bbb39316078d309c7c3384e9acf99ee5f2285813 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEOTY2OjFGOTE5RDpFMTdBQjE6MTQzRjFDRTo2QTVBMEIwMSIsInZpc2l0b3JfaWQiOiI3NTA4MjkwODg0NjU4MTM3ODU3IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | a22ac465ef81ef88bd080af803ab2f17ded74c31fb6a0ce9714412771eb87ac1 |
| hovercard-subject-tag | issue:2084677016 |
| 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/21081/issue_layout |
| twitter:image | https://opengraph.githubassets.com/5648346a5c9e6df3e79c96986672c89a1777a458a779ba644ccc5af99f552ec7/PowerShell/PowerShell/issues/21081 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/5648346a5c9e6df3e79c96986672c89a1777a458a779ba644ccc5af99f552ec7/PowerShell/PowerShell/issues/21081 |
| 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 | 8c2fe7351e4e987cb8f75e2425a0b895d807779bc4c2d3c312be0a54082219f7 |
| 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 | 491710c7a8eecca9d0a06bd157646f2685d8c87b |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width