I am new to powershell and I am trying to load and validate json data from a web url. This url will give the connection status of different interfaces. I am trying to return "1" if any of the test connection status equals Fail. I am getting errors when trying to loop through the parsed json data. Appreciate your help on this subject
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$request = 'https://connecttestservices.net/connection-test'
Invoke-WebRequest $request |
ConvertFrom_Json |
foreach ($request in $x) {
if ( $request.connectionTestStatus -match "FAIL" ) {
return 1
}
}