File tree Expand file tree Collapse file tree
EntraBeta/Microsoft.Entra.Beta/Users
Entra/Microsoft.Entra/Users Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -94,3 +94,43 @@ function Update-EntraInvitedUserSponsorsFromInvitedBy {
9494 Write-Verbose " Complete!"
9595 }
9696}
97+
98+ function Get-ObjectPropertyValue {
99+ [CmdletBinding ()]
100+ [OutputType ([psobject ])]
101+ param (
102+ # Object containing property values
103+ [Parameter (Mandatory = $true , Position = 0 , ValueFromPipeline = $true )]
104+ [AllowNull ()]
105+ [psobject ] $InputObjects ,
106+ # Name of property. Specify an array of property names to tranverse nested objects.
107+ [Parameter (Mandatory = $true , ValueFromRemainingArguments = $true )]
108+ [string []] $Property
109+ )
110+
111+ process {
112+ foreach ($InputObject in $InputObjects ) {
113+ for ($iProperty = 0 ; $iProperty -lt $Property.Count ; $iProperty ++ ) {
114+ # # Get property value
115+ if ($InputObject -is [hashtable ]) {
116+ if ($InputObject.ContainsKey ($Property [$iProperty ])) {
117+ $PropertyValue = $InputObject [$Property [$iProperty ]]
118+ }
119+ else { $PropertyValue = $null }
120+ }
121+ else {
122+ $PropertyValue = Select-Object - InputObject $InputObject - ExpandProperty $Property [$iProperty ] - ErrorAction Ignore
123+ if ($null -eq $PropertyValue ) { break }
124+ }
125+ # # Check for more nested properties
126+ if ($iProperty -lt $Property.Count - 1 ) {
127+ $InputObject = $PropertyValue
128+ if ($null -eq $InputObject ) { break }
129+ }
130+ else {
131+ Write-Output $PropertyValue
132+ }
133+ }
134+ }
135+ }
136+ }
Original file line number Diff line number Diff line change @@ -94,3 +94,42 @@ function Update-EntraBetaInvitedUserSponsorsFromInvitedBy {
9494 }
9595}
9696
97+ function Get-ObjectPropertyValue {
98+ [CmdletBinding ()]
99+ [OutputType ([psobject ])]
100+ param (
101+ # Object containing property values
102+ [Parameter (Mandatory = $true , Position = 0 , ValueFromPipeline = $true )]
103+ [AllowNull ()]
104+ [psobject ] $InputObjects ,
105+ # Name of property. Specify an array of property names to tranverse nested objects.
106+ [Parameter (Mandatory = $true , ValueFromRemainingArguments = $true )]
107+ [string []] $Property
108+ )
109+
110+ process {
111+ foreach ($InputObject in $InputObjects ) {
112+ for ($iProperty = 0 ; $iProperty -lt $Property.Count ; $iProperty ++ ) {
113+ # # Get property value
114+ if ($InputObject -is [hashtable ]) {
115+ if ($InputObject.ContainsKey ($Property [$iProperty ])) {
116+ $PropertyValue = $InputObject [$Property [$iProperty ]]
117+ }
118+ else { $PropertyValue = $null }
119+ }
120+ else {
121+ $PropertyValue = Select-Object - InputObject $InputObject - ExpandProperty $Property [$iProperty ] - ErrorAction Ignore
122+ if ($null -eq $PropertyValue ) { break }
123+ }
124+ # # Check for more nested properties
125+ if ($iProperty -lt $Property.Count - 1 ) {
126+ $InputObject = $PropertyValue
127+ if ($null -eq $InputObject ) { break }
128+ }
129+ else {
130+ Write-Output $PropertyValue
131+ }
132+ }
133+ }
134+ }
135+ }
You can’t perform that action at this time.
0 commit comments