Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invoke-SNOWWebRequest - Parameter error in PowerShell Core 7.3.x #62

Closed
ad-85 opened this issue May 17, 2024 · 1 comment
Closed

Invoke-SNOWWebRequest - Parameter error in PowerShell Core 7.3.x #62

ad-85 opened this issue May 17, 2024 · 1 comment
Labels
bug Something isn't working
Milestone

Comments

@ad-85
Copy link

ad-85 commented May 17, 2024

Describe the bug
When calling Invoke-SNOWWebRequest in PS Core 7.3.x, a ParameterBindingException is thrown. This is because the following code is used to determine which parameter name to use (due to the breaking change in PS Core version 7.4.0)

To Reproduce
Steps to reproduce the behavior:

(will only throw the error in PS 7.3.x)

  1. Import-Module PSSnow
  2. Set-SNOWAuth -Instance "dev123456" -Credential (get-credential)
  3. Get-SNOWUser -limit 5 -offset 5
  4. See error as per below:
Invoke-WebRequest:
Line |
1405 |  … Invoke-WebRequest @PSBoundParameters @ProxyAuth @TimeoutSplat -UseBas …
     |                                                    ~~~~~~~~~~~~~
     | A parameter cannot be found that matches parameter name 'OperationTimeoutSeconds'.

PS C:\Users\[username]> $PSVersionTable.PSVersion

PS C:\Users\[username]> (Get-Command "Invoke-WebRequest" | Select -Expand Parameters).Keys -match 'TimeoutSec'
TimeoutSec
PS C:\Users\[username]> 'TimeoutSec' -in (Get-Command "Invoke-WebRequest" | Select -Expand Parameters).Keys
True
PS C:\Users\[username]> 'OperationTimeoutSeconds' -in (Get-Command "Invoke-WebRequest" | Select -Expand Parameters).Keys
False

Major  Minor  Patch  PreReleaseLabel BuildLabel
-----  -----  -----  --------------- ----------
7      3      4

Expected behavior
The cmdlet should default to using TimeoutSec which is still present in 7.3. The below adjustment to the boolean check will resolve it:

Old:

PS C:\Users\[username]> $PSVersionTable.PSVersion.ToString() -gt 7.3
True

New:

PS C:\Users\[username]> $PSVersionTable.PSVersion.ToString() -ge 7.4
False

Environment (please complete the following information):

  • Module Version: 1.3.1
  • Powershell Version: 7.3.4
  • OS: Windows Server 2019
  • Servicenow Version: Vancouver

Additional context
Add any other context about the problem here.

@ad-85 ad-85 added the bug Something isn't working label May 17, 2024
@insomniacc
Copy link
Owner

Hey! I appreciate the detailed issue on this one, I'll get this in the next release 👍

@insomniacc insomniacc added this to the 1.3.2 milestone May 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants