How to parse JSON from the Invoke-WebRequest in PowerShell?

You could replace Invoke-WebRequest with Invoke-RestMethod which auto-converts json response to a psobject so you can use:

$response = Invoke-RestMethod -Uri "https://yadayada:8080/bla"
$response.flag 

If you have a need to use Invoke-WebRequest over Invoke-RestMethod you can convert it to an object by turning it into a string first

$response = Invoke-WebRequest -Uri "https://yadayada:8080/bla"
$jsonObj = ConvertFrom-Json $([String]::new($response.Content))

This way:

$response = Invoke-WebRequest -Uri <your_uri>
if ($response.statuscode -eq '200') {
    $keyValue= ConvertFrom-Json $response.Content | Select-Object -expand "<your_key_name>"
}