I am logging into Azure using azure cli as follows:
$login = az login
The output is as follows:
[
{
"cloudName": "AzureCloud",
"id": "xxxxxxxxxxxxxxxxxxx",
"isDefault": false,
"name": "ABC",
"state": "Enabled",
"tenantId": "yyyyyyyyyyyyy",
"user": {
"name": "xxxxxxx",
"type": "user"
}
},
{
"cloudName": "AzureCloud",
"id": "xxxxxxxxxxxxxxxxxxxx",
"isDefault": true,
"name": "PQR",
"state": "Enabled",
"tenantId": "yyyyyyyyyyyyyyyyyyyyyyyyyyyyy",
"user": {
"name": "xxxxxxxxxx",
"type": "user"
}
}
]
I want to fetch the id value whose name is PQR. I was expecting i could do this as follows:
$login[1].id
But turns out $login is not a json object. I tried doing $login | ConvertTo-Json. Not working as i want.
ConvertFrom-Json? The string is already JSON, you want an object out of it.$login.GetType()?