You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Modules/CIPPCore/Public/GraphHelper/Get-Tenants.ps1
+20-2Lines changed: 20 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -60,7 +60,19 @@ function Get-Tenants {
60
60
}
61
61
62
62
if ($CleanOld.IsPresent) {
63
-
$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
Write-LogMessage-API 'Get-Tenants'-message 'Tried cleaning old tenants but failed to get GDAP relationships - No relationships returned'-Sev 'Critical'
69
+
throw'Failed to get GDAP relationships for cleaning old tenants.'
70
+
}
71
+
} catch {
72
+
$ErrorMessage=Get-CippException-Exception $_
73
+
Write-LogMessage-API 'Get-Tenants'-message "Tried cleaning old tenants but failed to get GDAP relationships - $($_.Exception.Message)"-Sev 'Critical'-LogData $ErrorMessage
throw'RefreshToken not set. Cannot get tenant list.'
85
97
}
86
98
#get the full list of tenants
87
-
$GDAPRelationships=New-GraphGetRequest-uri "https://graph.microsoft.com/beta/tenantRelationships/delegatedAdminRelationships?`$filter=status eq 'active' and not startsWith(displayName,'MLT_')$RelationshipFilter&`$select=customer,autoExtendDuration,endDateTime&`$top=300"-NoAuthCheck:$true
0 commit comments