Retrieving information in Powershell from Az Devops result

Short answer: You should be able to get to the mailAddress property with $result.'DESCRIPTOR'.mailAddress.

Here is the why and how:

PS C:\> $result = az devops security group membership list --id "xxx" --organization "yyy" | ConvertFrom-Json
PS C:\> $result.GetType()

IsPublic IsSerial Name                                     BaseType
-------- -------- ----                                     --------
True     False    PSCustomObject                           System.Object

PS C:\Users\BHANNADE> $result | Get-Member

   TypeName: System.Management.Automation.PSCustomObject

Name                                                 MemberType   Definition
----                                                 ----------   ----------
Equals                                               Method       bool Equals(System.Object obj)
GetHashCode                                          Method       int GetHashCode()
GetType                                              Method       type GetType()
ToString                                             Method       string ToString()
aad.NmEzOTc1MTIt...xYr58NWZkLTg4MDQtY2QxZGUxODkzMWQ4 NoteProperty System.Management.Automation.PSCustomObject ...
aad.Y2I1NjM2NjIt...mZi03NzA5LTg4MWQtNDZjZmI5NjRjYWMy NoteProperty System.Management.Automation.PSCustomObject ...

This tells us that $result is a PowerShell Custom Object with the descriptors themselves as Members (NoteProperties).

Therefore, $result.'DESCRIPTOR'.mailAddress should let you get to the mailAddress property:

PS C:\> $result.'aad.NmEzOTc1MTIt...xYr58NWZkLTg4MDQtY2QxZGUxODkzMWQ4'.mailAddress
[email protected]


There may be multiple members in a Team and so your $result may contain multiple objects. You can extract all the email addresses as follows:

$properties = $result | Get-Member -MemberType Properties | Select-Object -ExpandProperty Name
$mailAddresses = @()
$mailAddresses += $properties.ForEach({$result.$_.mailAddress})

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top