Skip to content

Commit 4b5b11b

Browse files
committed
Sort both tenant groups and tenants in a group
1 parent e05affb commit 4b5b11b

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/CIPP/Settings/Invoke-ListTenantGroups.ps1

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ function Invoke-ListTenantGroups {
1212

1313
$groupFilter = $Request.Query.groupId ?? $Request.Body.groupId
1414
$TenantGroups = (Get-TenantGroups -GroupId $groupFilter) ?? @()
15-
$SortedTenantGroups = $TenantGroups | Sort-Object Name
16-
$Body = @{ Results = @($SortedTenantGroups) }
15+
$Body = @{ Results = @($TenantGroups) }
1716

1817
Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{
1918
StatusCode = [HttpStatusCode]::OK

Modules/CIPPCore/Public/Functions/Get-TenantGroups.ps1

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,18 +43,21 @@ function Get-TenantGroups {
4343
}
4444

4545
if ($TenantFilter -and $TenantFilter -ne 'allTenants') {
46+
$Results = @()
4647
$Memberships = $AllMembers | Where-Object { $_.customerId -eq $Tenants.customerId }
4748
foreach ($Group in $Memberships) {
4849
$Group = $Groups | Where-Object { $_.RowKey -eq $Group.GroupId }
4950
if ($Group) {
50-
[PSCustomObject]@{
51+
$Results += [PSCustomObject]@{
5152
Id = $Group.RowKey
5253
Name = $Group.Name
5354
Description = $Group.Description
5455
}
5556
}
5657
}
58+
return $Results | Sort-Object Name
5759
} else {
60+
$Results = @()
5861
$Groups | ForEach-Object {
5962
$Group = $_
6063
$Members = $AllMembers | Where-Object { $_.GroupId -eq $Group.RowKey }
@@ -75,14 +78,16 @@ function Get-TenantGroups {
7578
}
7679
if (!$Members) {
7780
$Members = @()
81+
} else {
82+
$Members = $Members | Sort-Object displayName
7883
}
79-
80-
[PSCustomObject]@{
84+
$Results += [PSCustomObject]@{
8185
Id = $Group.RowKey
8286
Name = $Group.Name
8387
Description = $Group.Description
8488
Members = @($Members)
8589
}
8690
}
91+
return $Results | Sort-Object Name
8792
}
8893
}

0 commit comments

Comments
 (0)