Home > Net >  Extract group id string from powershell azure
Extract group id string from powershell azure

Time:10-27

I'm have some groups on azure, which I'm retriving with Get-AzADGroup like so:

Get-AzADGroup -Filter "startsWith(DisplayName, 'groupname')"

which yields the displayname, the id, the mailnickname and the discription..

What I want to do is to get the ID only and put it into a variable. How do I do this?

CodePudding user response:

To return only specific properties, you can pipe the results into Select-Object and specify which properties

$variable = Get-AzADGroup -Filter "startsWith(DisplayName, 'groupname')" | Select-Object Id

Alternatively, you can store the entire results in the variable, and use dot-notation to get a specific property

$variable = Get-AzADGroup -Filter "startsWith(DisplayName, 'groupname')"

$variable.Id

CodePudding user response:

  • Related