Title: Invoke-WebRequest -OutLeaf · Issue #20010 · PowerShell/PowerShell · GitHub
Open Graph Title: Invoke-WebRequest -OutLeaf · Issue #20010 · PowerShell/PowerShell
X Title: Invoke-WebRequest -OutLeaf · Issue #20010 · PowerShell/PowerShell
Description: Summary of the new feature / enhancement I would like an ability to download a file with Invoke-WebRequest without explicitly providing its name, same as with curl -O. The filename should be deduced from the uri, equivalent to -Uri $Uri ...
Open Graph Description: Summary of the new feature / enhancement I would like an ability to download a file with Invoke-WebRequest without explicitly providing its name, same as with curl -O. The filename should be deduce...
X Description: Summary of the new feature / enhancement I would like an ability to download a file with Invoke-WebRequest without explicitly providing its name, same as with curl -O. The filename should be deduce...
Opengraph URL: https://github.com/PowerShell/PowerShell/issues/20010
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Invoke-WebRequest -OutLeaf","articleBody":"### Summary of the new feature / enhancement\r\n\r\nI would like an ability to download a file with `Invoke-WebRequest` without explicitly providing its name, same as with `curl -O`. The filename should be deduced from the uri, equivalent to `-Uri $Uri -OutFile (Split-Path $Uri)`. If the uri contains query parameters, they are either discarded (`test.txt?param=value` results in `test.txt`), or an error should be given.\r\n\r\nMotivating example can be seen in [`Invoke-WebRequest` example #8](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/invoke-webrequest?view=powershell-7.3#example-8-download-multiple-files-at-the-same-time), the filename is typed twice for every file - once in `Uri` and once in `OutFile`.\r\n\r\nAdditionally, I think that `-OutLeaf` without `-PassThru` should return the full resolved path to the downloaded file, so that it can be stored or piped into `Start-Process` or `Invoke-Command` for immediate execution (useful for e.g. installers).\r\n\r\nSimilar proposals were made in:\r\n* https://github.com/PowerShell/PowerShell/issues/17554 - Closed due high complexity\r\n* https://github.com/PowerShell/PowerShell/issues/17553 - Closed due overzealous @msftbot \r\n\r\nI agree with the latter, that `-OutDirectory` could be an alternative API, so that you can get `Invoke-WebRequest -OutLeaf` with `Invoke-WebRequest -OutDirectory .`, while also allowing to download files with implicit filename to a different directory.\r\n\r\nOpens:\r\n* Should the filename be url-decoded? I.e. should `Invoke-WebRequest example.com/file%20with%space.txt -OutLeaf` result in `file%20with%20space.txt` or `file with space.txt`? I would say latter, `curl` says former.\r\n\r\n### Proposed technical implementation details (optional)\r\n\r\n_No response_","author":{"url":"https://github.com/dkaszews","@type":"Person","name":"dkaszews"},"datePublished":"2023-07-22T08:15:50.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":3},"url":"https://github.com/20010/PowerShell/issues/20010"}
| 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:9df2a33f-4eb1-ed07-74e8-ea1adca38e5d |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A3C2:5AF22:1821DBE:2311DE2:6A54E6FB |
| html-safe-nonce | db81d66d7cea347b96ba0a8e8cd7dd331f4dbc1b849234dfde44d2892246ef2b |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBM0MyOjVBRjIyOjE4MjFEQkU6MjMxMURFMjo2QTU0RTZGQiIsInZpc2l0b3JfaWQiOiI0NzU3ODI0OTI4MTU3NTkxMjkxIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 6b8c494280d182c334a21c4d6876e74e36fe049948e21ad2e28a735db647c39f |
| hovercard-subject-tag | issue:1816677127 |
| 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/20010/issue_layout |
| twitter:image | https://opengraph.githubassets.com/542e67ec94311da8a8d2a44a96bbdd594b2804a1920797c78f906c4d4c44645c/PowerShell/PowerShell/issues/20010 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/542e67ec94311da8a8d2a44a96bbdd594b2804a1920797c78f906c4d4c44645c/PowerShell/PowerShell/issues/20010 |
| og:image:alt | Summary of the new feature / enhancement I would like an ability to download a file with Invoke-WebRequest without explicitly providing its name, same as with curl -O. The filename should be deduce... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | dkaszews |
| 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 | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width