OneIdentity / safeguard-ps

One Identity Safeguard PowerShell scripting resources
Apache License 2.0
22 stars 27 forks source link

Fix for PowerShell 7.4 Issue #20744 with -OutFile for Invoke-WebRequest and Invoke-RestMethod #513

Closed sthayduk closed 10 months ago

sthayduk commented 10 months ago

Starting with PowerShell 7.4, there has been a change in the behavior of the -OutFile parameter, particularly in its handling of $null values. As a result, the existing implementation of the Request may trigger an exception, preventing any requests from being sent to the Safeguard REST API.

To address this, the proposed fix involves validating whether $OutFile is set prior to passing it to the Invoke-WebRequest or Invoke-RestMethod commands.

https://github.com/PowerShell/PowerShell/issues/20744

petrsnd commented 10 months ago

@sthayduk Thanks for submitting a fix. We consolidated the code a little more in another PR and merged it today. It was also broken for the -InFile parameter.

petrsnd commented 10 months ago

See #514