Hi, I am running the following script:
add-type "using System.Net; using System.Security.Cryptography.X509Certificates; public class TrustAllCertsPolicy : ICertificatePolicy{ public bool CheckValidationResult(ServicePoint srvPoint, X509Certificate certificate, WebRequest request, int certificateProblem) { return true; }}"; [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; [System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy; Invoke-WebRequest -Uri 'https://us-west1.cloud.twistlock.com/us-3-159184149/api/v1/scripts/defender.ps1' -Headers @{"authorization" = "Bearer ...." } -OutFile C:\Scripts\defender.ps1;
I returned this error:
Invoke-WebRequest : {"err":""} At line:1 char:1 + Invoke-WebRequest -Uri 'https://us-west1.cloud.twistlock.com/us-3-159 ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest], WebException + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand
I’m curious whether there’s any recommendation? Thank you.