@@ -19,7 +19,14 @@ function Invoke-ListGroups {
1919 $GroupType = $Request.Query.groupType
2020 $Members = $Request.Query.members
2121 $Owners = $Request.Query.owners
22- $SelectString = ' id,createdDateTime,displayName,description,mail,mailEnabled,mailNickname,resourceProvisioningOptions,securityEnabled,visibility,organizationId,onPremisesSamAccountName,membershipRule,groupTypes,onPremisesSyncEnabled,resourceProvisioningOptions,userPrincipalName&$expand=members($select=userPrincipalName)'
22+
23+ $ExpandMembers = $Request.Query.expandMembers ?? $false
24+
25+ $SelectString = ' id,createdDateTime,displayName,description,mail,mailEnabled,mailNickname,resourceProvisioningOptions,securityEnabled,visibility,organizationId,onPremisesSamAccountName,membershipRule,groupTypes,onPremisesSyncEnabled,resourceProvisioningOptions,userPrincipalName'
26+ if ($ExpandMembers -ne $false ) {
27+ $SelectString = ' {0}&$expand=members($select=userPrincipalName)' -f $SelectString
28+ }
29+
2330
2431 $BulkRequestArrayList = [System.Collections.Generic.List [object ]]::new()
2532
@@ -86,7 +93,7 @@ function Invoke-ListGroups {
8693 $RawGraphRequest = New-GraphBulkRequest - tenantid $TenantFilter - scope ' https://graph.microsoft.com/.default' - Requests @ ($BulkRequestArrayList ) - asapp $true
8794 $GraphRequest = [PSCustomObject ]@ {
8895 groupInfo = ($RawGraphRequest | Where-Object { $_.id -eq 1 }).body | Select-Object * , @ { Name = ' primDomain' ; Expression = { $_.mail -split ' @' | Select-Object - Last 1 } },
89- @ {Name = ' teamsEnabled' ; Expression = { if ($_.resourceProvisioningOptions -Like ' *Team*' ) { $true } else { $false } } },
96+ @ {Name = ' teamsEnabled' ; Expression = { if ($_.resourceProvisioningOptions -like ' *Team*' ) { $true } else { $false } } },
9097 @ {Name = ' calculatedGroupType' ; Expression = {
9198 if ($_.mailEnabled -and $_.securityEnabled ) { ' Mail-Enabled Security' }
9299 if (! $_.mailEnabled -and $_.securityEnabled ) { ' Security' }
@@ -129,4 +136,4 @@ function Invoke-ListGroups {
129136 Body = $GraphRequest
130137 })
131138
132- }
139+ }
0 commit comments