Fortra

How can I access the Cloud Defender API with a PowerShell script using the Invoke-WebRequest command?

Comments

3 comments

  • Avatar
    Evan Cunningham

    For some Powershell users consider using...

       $headers = @{}

       $headers.Add("Accept","application/json" )

       $headers.Add("Authorization",$basicAuthValue)

    ...technique for adding headers individually. the example as provided is potentially flawed, with PS not recognizing the reserved word Authorization as a valid value for the array.

    Adding them separately worked for me.

    Thanks,

    EC

    1
  • Avatar
    Abby Kincer

    Thanks for sharing this, Evan! We're going to run it by our technical support team to see if it's valuable to add into the article. Your feedback is much appreciated.

    0
  • Avatar
    Welly Siauw

    In case you would like to see the entire response, please consider to add -Depth to the last command in the pipe:

    Invoke-WebRequest -uri $RemoteHost -Headers &headers | ConvertFrom-Json | ConvertTo-JSON -Depth 5

    1

Please sign in to leave a comment.