Skip to content

Commit 3de0eae

Browse files
committed
add goose code: add calculatedGroupType to user group output
1 parent 2e2aaa8 commit 3de0eae

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/Identity/Administration/Users/Invoke-ListUserGroups.ps1

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Function Invoke-ListUserGroups {
2222
$UserID = $Request.Query.UserID
2323

2424

25-
$URI = "https://graph.microsoft.com/beta/users/$UserID/memberOf/$/microsoft.graph.group?`$select=id,displayName,mailEnabled,securityEnabled,groupTypes,onPremisesSyncEnabled,mail,isAssignableToRole`&$orderby=displayName asc"
25+
$URI = "https://graph.microsoft.com/beta/users/$UserID/memberOf/$/microsoft.graph.group?`$select=id,displayName,mailEnabled,securityEnabled,groupTypes,onPremisesSyncEnabled,mail,isAssignableToRole`&`$orderby=displayName asc"
2626
Write-Host $URI
2727
$GraphRequest = New-GraphGetRequest -uri $URI -tenantid $TenantFilter -noPagination $true -verbose | Select-Object id,
2828
@{ Name = 'DisplayName'; Expression = { $_.displayName } },
@@ -31,7 +31,14 @@ Function Invoke-ListUserGroups {
3131
@{ Name = 'SecurityGroup'; Expression = { $_.securityEnabled } },
3232
@{ Name = 'GroupTypes'; Expression = { $_.groupTypes -join ',' } },
3333
@{ Name = 'OnPremisesSync'; Expression = { $_.onPremisesSyncEnabled } },
34-
@{ Name = 'IsAssignableToRole'; Expression = { $_.isAssignableToRole } }
34+
@{ Name = 'IsAssignableToRole'; Expression = { $_.isAssignableToRole } },
35+
@{ Name = 'calculatedGroupType'; Expression = {
36+
if ($_.mailEnabled -and $_.securityEnabled) { 'Mail-Enabled Security' }
37+
if (!$_.mailEnabled -and $_.securityEnabled) { 'Security' }
38+
if ($_.groupTypes -contains 'Unified') { 'Microsoft 365' }
39+
if (([string]::isNullOrEmpty($_.groupTypes)) -and ($_.mailEnabled) -and (!$_.securityEnabled)) { 'Distribution List' }
40+
}
41+
}
3542

3643

3744
# Associate values to output bindings by calling 'Push-OutputBinding'.

0 commit comments

Comments
 (0)