-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Closed
Closed
Copy link
Labels
Resolution-FixedThe issue is fixed.The issue is fixed.WG-Cmdlets-Utilitycmdlets in the Microsoft.PowerShell.Utility modulecmdlets in the Microsoft.PowerShell.Utility module
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 reproduce
I 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.
When testing PWSH v7.4.0-preview2, all script-based modules and IRM/IWR throw an error.
Eg. https://github.com/dell/OpenManage-PowerShell-Modules
I believe this is part of PR #18595. It seems that in certain scenarios, the change is breaking.
Adding 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.
if ($psVersionTable.PSVersion.Major -ge 7 -and $psVersionTable.PSVersion.Minor -ge 4) {
$querySplat.Add('AllowInsecureRedirect',$true)
}
Expected behavior
[2881.31]ms GitHub> # Works before 7.4.0-preview2
$querySplat = @{
Method = 'POST'
URI = $URI
Body = $bodyJSON
SkipCertificateCheck = $true
ContentType = 'application/json'
}
Invoke-RestMethod @querySplat
Id : a1bf17dd-d590-4929-8f0a-7357bed828f8
Description : abcde.ab@OU=Groups,DC=test,DC=Contosa,DC=com
Name : API
...Actual behavior
[2881.31]ms GitHub> # Works before 7.4.0-preview2
$querySplat = @{
Method = 'POST'
URI = $URI
Body = $bodyJSON
SkipCertificateCheck = $true
ContentType = 'application/json'
}
Invoke-RestMethod @querySplat
Invoke-RestMethod:
Line |
9 | Invoke-RestMethod @querySplat
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| This operation is not supported for a relative URI.
### Error details
```console
Exception :
Type : System.InvalidOperationException
TargetSite :
Name : get_Scheme
DeclaringType : uri
MemberType : Method
Module : System.Private.Uri.dll
Message : This operation is not supported for a relative URI.
Source : System.Private.Uri
HResult : -2146233079
StackTrace :
at System.Uri.get_Scheme()
at Microsoft.PowerShell.Commands.WebRequestPSCmdlet.ProcessRecord()
at System.Management.Automation.CommandProcessor.ProcessRecord()
CategoryInfo : NotSpecified: (:) [Invoke-RestMethod], InvalidOperationException
FullyQualifiedErrorId : System.InvalidOperationException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand
InvocationInfo :
MyCommand : Invoke-RestMethod
ScriptLineNumber : 8
OffsetInLine : 1
HistoryId : 8
Line : Invoke-RestMethod @querySplat
Statement : Invoke-RestMethod @querySplat
PositionMessage : At line:8 char:1
+ Invoke-RestMethod @querySplat
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
InvocationName : Invoke-RestMethod
CommandOrigin : Internal
ScriptStackTrace : at <ScriptBlock>, <No file>: line 8
Environment data
Name Value
---- -----
PSVersion 7.4.0-preview.2
PSEdition Core
GitCommitId 7.4.0-preview.2
OS Microsoft Windows 10.0.19045
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0Visuals
No response
Metadata
Metadata
Assignees
Labels
Resolution-FixedThe issue is fixed.The issue is fixed.WG-Cmdlets-Utilitycmdlets in the Microsoft.PowerShell.Utility modulecmdlets in the Microsoft.PowerShell.Utility module