Skip to content

Commit dc2d4cf

Browse files
committed
improve ListTenants
1 parent 4357c79 commit dc2d4cf

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/Tenant/Administration/Tenant/Invoke-ListTenants.ps1

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,16 @@ function Invoke-ListTenants {
7070
}
7171
try {
7272
$TenantFilter = $Request.Query.tenantFilter
73-
$Tenants = Get-Tenants -IncludeErrors -SkipDomains
73+
$tenantParams = @{
74+
IncludeErrors = $true
75+
SkipDomains = $true
76+
}
77+
if ($TenantFilter -and $TenantFilter -ne 'AllTenants') {
78+
$tenantParams['TenantFilter'] = $TenantFilter
79+
}
80+
81+
$Tenants = Get-Tenants @tenantParams
82+
7483
if ($TenantAccess -notcontains 'AllTenants') {
7584
$Tenants = $Tenants | Where-Object -Property customerId -In $TenantAccess
7685
}
@@ -98,7 +107,7 @@ function Invoke-ListTenants {
98107
}
99108
}
100109

101-
if ($null -eq $TenantFilter -or $TenantFilter -eq 'null') {
110+
if (($null -eq $TenantFilter -or $TenantFilter -eq 'null') -or $Request.Query.Mode -eq 'TenantList') {
102111
$TenantList = [system.collections.generic.list[object]]::new()
103112
if ($AllTenantSelector -eq $true) {
104113
$AllTenantsObject = @{
@@ -141,7 +150,7 @@ function Invoke-ListTenants {
141150
}
142151

143152
} else {
144-
$body = $Tenants | Where-Object -Property defaultDomainName -EQ $TenantFilter
153+
$body = $Tenants
145154
}
146155

147156
Write-LogMessage -headers $Headers -tenant $TenantFilter -API $APIName -message 'Listed Tenant Details' -Sev 'Debug'

0 commit comments

Comments
 (0)