Hello I am trying to create a service account using the below az cli commands. I am trying to fetch the appId and password into a powershell object using Jmespath. This is what I am trying to do.
$serviceprincipalname ="k8ssp"
$spdetails = $( az ad sp create-for-rbac `
--name $serviceprincipalname `
--query [appId, password])
write-output $spdetails
write-output $spdetails[0]
However the Jmespath query fails with the below error
az ad sp create-for-rbac: error: argument --query: invalid jmespath_type value: '[appId'
How can I select both the appId and password into a single object so that I can later split it and use it ?
You can use --query "[appId, password]" -o tsv
$result=(az ad sp create-for-rbac --name $serviceprincipalname --query "[appId, password]" -o tsv)