Thursday, November 10, 2016

Web Request using PowerShell and Parse JSON response as PowerShell object

To send web request and read JSON response using PowerShell I used following commands

$response = Invoke-WebRequest -Uri "http://myserver.com" -Method Get -Headers @{"apikey"="toekn"}
$responseAsPSObject = $response.Content | ConvertFrom-Json
$myValue = $responseAsPSObject.Value."mykey"
Write-Host "$myValue"


No comments: