Title: Insecure Proxy Behavior with Invoke-(RestMethod|WebRequest) on 7.4.0-preview2 · Issue #19461 · PowerShell/PowerShell · GitHub
Open Graph Title: Insecure Proxy Behavior with Invoke-(RestMethod|WebRequest) on 7.4.0-preview2 · Issue #19461 · PowerShell/PowerShell
X Title: Insecure Proxy Behavior with Invoke-(RestMethod|WebRequest) on 7.4.0-preview2 · Issue #19461 · 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/19461
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Insecure Proxy Behavior with Invoke-(RestMethod|WebRequest) on 7.4.0-preview2","articleBody":"### Prerequisites\n\n- [X] Write a descriptive title.\n- [X] Make sure you are able to repro it on the [latest released version](https://github.com/PowerShell/PowerShell/releases)\n- [X] Search the existing issues.\n- [X] Refer to the [FAQ](https://github.com/PowerShell/PowerShell/blob/master/docs/FAQ.md).\n- [X] Refer to [Differences between Windows PowerShell 5.1 and PowerShell](https://docs.microsoft.com/powershell/scripting/whats-new/differences-from-windows-powershell).\n\n### Steps to reproduce\n\nI use a number of script-based PWSH modules. In addition to using `Invoke-RestMethod` for a lot of API calls. These calls/modules are executed in a corporate environment with insecure/zero-trust proxies all over the place. The proxies cannot be avoided.\r\n\r\nWhen testing PWSH v7.4.0-preview2, all script-based modules and IRM/IWR throw an error.\r\nEg. https://github.com/dell/OpenManage-PowerShell-Modules\r\n\r\nI believe this is part of PR #18595. It seems that in certain scenarios, the change is breaking.\r\n\r\nAdding the following to script-based modules and repos would be a large effort with external modules being out of my control. Unclear of best approach to mitigate in order to work before/after the 7.4.0 threshold.\r\n```\r\nif ($psVersionTable.PSVersion.Major -ge 7 -and $psVersionTable.PSVersion.Minor -ge 4) {\r\n $querySplat.Add('AllowInsecureRedirect',$true)\r\n}\r\n```\n\n### Expected behavior\n\n```console\n[2881.31]ms GitHub\u003e # Works before 7.4.0-preview2\r\n$querySplat = @{\r\n Method = 'POST'\r\n URI = $URI\r\n Body = $bodyJSON\r\n SkipCertificateCheck = $true\r\n ContentType = 'application/json'\r\n}\r\nInvoke-RestMethod @querySplat\r\nId : a1bf17dd-d590-4929-8f0a-7357bed828f8 \r\nDescription : abcde.ab@OU=Groups,DC=test,DC=Contosa,DC=com\r\nName : API\r\n...\n```\n\n\n### Actual behavior\n\n```console\n[2881.31]ms GitHub\u003e # Works before 7.4.0-preview2\r\n$querySplat = @{\r\n Method = 'POST'\r\n URI = $URI\r\n Body = $bodyJSON\r\n SkipCertificateCheck = $true\r\n ContentType = 'application/json'\r\n}\r\nInvoke-RestMethod @querySplat\r\n\r\nInvoke-RestMethod: \r\nLine |\r\n 9 | Invoke-RestMethod @querySplat\r\n | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r\n | This operation is not supported for a relative URI.\r\n```\n```\n\n\n### Error details\n\n```console\nException : \r\n Type : System.InvalidOperationException\r\n TargetSite : \r\n Name : get_Scheme\r\n DeclaringType : uri\r\n MemberType : Method\r\n Module : System.Private.Uri.dll\r\n Message : This operation is not supported for a relative URI.\r\n Source : System.Private.Uri\r\n HResult : -2146233079\r\n StackTrace : \r\n at System.Uri.get_Scheme()\r\n at Microsoft.PowerShell.Commands.WebRequestPSCmdlet.ProcessRecord()\r\n at System.Management.Automation.CommandProcessor.ProcessRecord()\r\nCategoryInfo : NotSpecified: (:) [Invoke-RestMethod], InvalidOperationException\r\nFullyQualifiedErrorId : System.InvalidOperationException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand\r\nInvocationInfo : \r\n MyCommand : Invoke-RestMethod\r\n ScriptLineNumber : 8\r\n OffsetInLine : 1\r\n HistoryId : 8\r\n Line : Invoke-RestMethod @querySplat \r\n Statement : Invoke-RestMethod @querySplat \r\n PositionMessage : At line:8 char:1\r\n + Invoke-RestMethod @querySplat \r\n + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r\n InvocationName : Invoke-RestMethod\r\n CommandOrigin : Internal\r\nScriptStackTrace : at \u003cScriptBlock\u003e, \u003cNo file\u003e: line 8\n```\n\n\n### Environment data\n\n```powershell\nName Value\r\n---- -----\r\nPSVersion 7.4.0-preview.2\r\nPSEdition Core\r\nGitCommitId 7.4.0-preview.2\r\nOS Microsoft Windows 10.0.19045\r\nPlatform Win32NT\r\nPSCompatibleVersions {1.0, 2.0, 3.0, 4.0…} \r\nPSRemotingProtocolVersion 2.3\r\nSerializationVersion 1.1.0.1\r\nWSManStackVersion 3.0\n```\n\n\n### Visuals\n\n_No response_","author":{"url":"https://github.com/crlogic","@type":"Person","name":"crlogic"},"datePublished":"2023-04-06T21:43:26.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":19},"url":"https://github.com/19461/PowerShell/issues/19461"}
| 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:2a465529-33b2-774c-e57a-7616b6652ac1 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D350:3280E7:1C9DADF:261DF2A:6A545564 |
| html-safe-nonce | 974c1f7e0af7129db9779187bd9870b48a4d3b9965f09de537a4c7216c59d962 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEMzUwOjMyODBFNzoxQzlEQURGOjI2MURGMkE6NkE1NDU1NjQiLCJ2aXNpdG9yX2lkIjoiNTI2OTkwMjE4MzY2MzY4NzAxMiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | af8ac89e07880b0e5c988277ebc7312cc60b425845b674fe475ab8db1f2ac495 |
| hovercard-subject-tag | issue:1658080778 |
| 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/19461/issue_layout |
| twitter:image | https://opengraph.githubassets.com/fe5afbfce8d23124452a8c69475e46e625c6b6bc7f5fb1de32687c6ed6f62ae1/PowerShell/PowerShell/issues/19461 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/fe5afbfce8d23124452a8c69475e46e625c6b6bc7f5fb1de32687c6ed6f62ae1/PowerShell/PowerShell/issues/19461 |
| 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 | crlogic |
| hostname | github.com |
| expected-hostname | github.com |
| None | b9a586c06a05a7a86fc7e3f4dbd03e42f6869085879aa184aa6369456dbd50fb |
| 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 | 07a982c1d40157c619b364352b704c3ce66bb332 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width