Tips and Tricks

How to get value for a property from a object in Powershell Variable ?

Powershell

How to get value for a property from every object in Powershell Variable?

PS> Get-AzADGroup -DisplayName "my-group" | Select Idoutput will be like -
Id
--
2xc3cc-3frf5g-r4fe34c-xxxxx-something
We can use Select-Object to extract a single property value, via 
-ExpandProperty <PropertyName> parameter:
PS> Get-AzADGroup -DisplayName "developers" | Select
-ExpandProperty Id

2xc3cc-3frf5g-r4fe34c-xxxxx-something
PS> Get-AzADGroup -DisplayName "developers" | Get-MemberTypeName: Microsoft.Azure.Commands.ActiveDirectory.PSADGroupName            MemberType Definition
---- ---------- ----------
Equals Method bool Equals(System.Object obj)
GetHashCode Method int GetHashCode()
GetType Method type GetType()
ToString Method string ToString()
Description Property string Description {get;set;}
DisplayName Property string DisplayName {get;set;}
Id Property string Id {get;set;}
MailNickname Property string MailNickname {get;set;}
ObjectType Property string ObjectType {get;}
SecurityEnabled Property System.Nullable[bool] SecurityEnabled {get;set;}
Type Property string Type {get;set;}
PS> $ObjId = (Get-AzADGroup -DisplayName "developers").Id
PS> Write-Host $ObjId
2xc3cc-3frf5g-r4fe34c-xxxxx-something

In quest of understanding How Systems Work !

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store