Skip to content

Commit 2848860

Browse files
committed
add toggle for expanding group members
1 parent bcf23e1 commit 2848860

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/Identity/Administration/Groups/Invoke-ListGroups.ps1

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)