You can reference it using dot notation with your variables.
$json.$key
So, in your Write-Host you will need a subexpression if you used quotes in your hosting
Write-Host "Key is: $($json.$key)"
You tried to use array notation and returned null.
source
share