Welcome › Forums › General PowerShell Q&A › Invoke-WebRequest
- This topic has 1 reply, 2 voices, and was last updated 4 months, 3 weeks ago by
Participant.
Viewing 1 reply thread
-
AuthorPosts
-
-
September 4, 2020 at 1:32 pm #254624
Hi, I am running the following script:
PowerShell123add-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:
PowerShell123456Invoke-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.InvokeWebRequestCommandI’m curious whether there’s any recommendation? Thank you.
-
This topic was modified 4 months, 3 weeks ago by
grokkit. Reason: code formatting
-
This topic was modified 4 months, 3 weeks ago by
-
September 4, 2020 at 2:48 pm #254639
Did you make another web call to get your token? You will likely need a call to get your bearer token first.
-
-
AuthorPosts
Viewing 1 reply thread
- The topic ‘Invoke-WebRequest’ is closed to new replies.