0

I am trying to query my azure ad group and wants to print multiple parameter. However, nothing is working.

Following works to print only displayName

az ad group member list -g xxx --query [].displayName

I want to print displayName and userPrincipalName as well. However none of the following is working

az ad group member list -g xxx--query [].userPrincipalName, [].displayName

az ad group member list -g xxx--query [].{userPrincipalName, displayName}

az ad group member list -g xxx--query []{.userPrincipalName, .displayName}



Gaurang Shah
  • 11,764
  • 9
  • 74
  • 137

1 Answers1

2

This should work, you need to specify aliases for each field:

az ad group member list -g xxx --query -query "[].{userPrincipalName:userPrincipalName, displayName:displayName}"

Note that you need to quote the query.

Actually, there is a second option as well:

az ad group member list -g xxx --query "[].[userPrincipalName, displayName]"

But the first option returns an array of objects, the second an array of arrays. I'd prefer the first one.

silent
  • 14,494
  • 4
  • 46
  • 86