Skip to content

Commit b0127f3

Browse files
author
rvdwegen
committed
remove MLT odata filter
1 parent d4830f6 commit b0127f3

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

Modules/CIPPCore/Public/GraphHelper/Get-Tenants.ps1

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,9 @@ function Get-Tenants {
6161

6262
if ($CleanOld.IsPresent) {
6363
try {
64-
$GDAPRelationships = New-GraphGetRequest -uri "https://graph.microsoft.com/beta/tenantRelationships/delegatedAdminRelationships?`$filter=status eq 'active' and not startsWith(displayName,'MLT_')&`$select=customer,autoExtendDuration,endDateTime&`$top=300" -NoAuthCheck:$true
64+
$GDAPRelationships = New-GraphGetRequest -uri "https://graph.microsoft.com/beta/tenantRelationships/delegatedAdminRelationships?`$filter=status eq 'active'&`$select=customer,autoExtendDuration,endDateTime" -NoAuthCheck:$true
65+
# Filter out MLT relationships locally
66+
$GDAPRelationships = $GDAPRelationships | Where-Object { $_.displayName -notlike 'MLT_*' }
6567
if (!$GDAPRelationships) {
6668
Write-LogMessage -API 'Get-Tenants' -message 'Tried cleaning old tenants but failed to get GDAP relationships - No relationships returned' -Sev 'Critical'
6769
throw 'Failed to get GDAP relationships for cleaning old tenants.'
@@ -94,7 +96,9 @@ function Get-Tenants {
9496
throw 'RefreshToken not set. Cannot get tenant list.'
9597
}
9698
#get the full list of tenants
97-
$GDAPRelationships = New-GraphGetRequest -uri "https://graph.microsoft.com/v1.0/tenantRelationships/delegatedAdminRelationships?`$filter=status eq 'active' and not startsWith(displayName,'MLT_')$RelationshipFilter&`$select=customer,autoExtendDuration,endDateTime" -NoAuthCheck:$true
99+
$GDAPRelationships = New-GraphGetRequest -uri "https://graph.microsoft.com/v1.0/tenantRelationships/delegatedAdminRelationships?`$filter=status eq 'active'$RelationshipFilter&`$select=customer,autoExtendDuration,endDateTime" -NoAuthCheck:$true
100+
# Filter out MLT relationships locally
101+
$GDAPRelationships = $GDAPRelationships | Where-Object { $_.displayName -notlike 'MLT_*' }
98102
Write-Host "GDAP relationships found: $($GDAPRelationships.Count)"
99103
Write-Information "GDAP relationships found: $($GDAPRelationships.Count)"
100104
$totalTenants = $GDAPRelationships.customer.tenantId | Select-Object -Unique

0 commit comments

Comments
 (0)