@@ -56,18 +56,6 @@ function New-GraphGetRequest {
5656 $headers [' User-Agent' ] = " CIPP/$ ( $global :CippVersion ?? ' 1.0' ) "
5757 }
5858
59- # Track consecutive Graph API failures
60- $TenantsTable = Get-CippTable - tablename Tenants
61- $Filter = " PartitionKey eq 'Tenants' and (defaultDomainName eq '{0}' or customerId eq '{0}')" -f $tenantid
62- $Tenant = Get-CIPPAzDataTableEntity @TenantsTable - Filter $Filter
63- if (! $Tenant ) {
64- $Tenant = @ {
65- GraphErrorCount = 0
66- LastGraphError = ' '
67- PartitionKey = ' TenantFailed'
68- RowKey = ' Failed'
69- }
70- }
7159
7260 $ReturnedData = do {
7361 $RetryCount = 0
@@ -185,31 +173,11 @@ function New-GraphGetRequest {
185173 $RetryCount ++
186174 Start-Sleep - Seconds $WaitTime
187175 } else {
188- # Final failure - update tenant error tracking and throw
189- if ($Message -ne ' Request not applicable to target tenant.' -and $Tenant ) {
190- $Tenant.LastGraphError = [string ]($MessageObj | ConvertTo-Json - Compress)
191- if ($Tenant.PSObject.Properties.Name -notcontains ' GraphErrorCount' ) {
192- $Tenant | Add-Member - MemberType NoteProperty - Name ' GraphErrorCount' - Value 0 - Force
193- }
194- $Tenant.GraphErrorCount ++
195- Update-AzDataTableEntity - Force @TenantsTable - Entity $Tenant
196- }
197176 throw $Message
198177 }
199178 }
200179 } while (-not $RequestSuccessful -and $RetryCount -le $MaxRetries )
201180 } until ([string ]::IsNullOrEmpty($NextURL ) -or $NextURL -is [object []] -or ' ' -eq $NextURL )
202- if ($Tenant.PSObject.Properties.Name -notcontains ' LastGraphError' ) {
203- $Tenant | Add-Member - MemberType NoteProperty - Name ' LastGraphError' - Value ' ' - Force
204- } else {
205- $Tenant.LastGraphError = ' '
206- }
207- if ($Tenant.PSObject.Properties.Name -notcontains ' GraphErrorCount' ) {
208- $Tenant | Add-Member - MemberType NoteProperty - Name ' GraphErrorCount' - Value 0 - Force
209- } else {
210- $Tenant.GraphErrorCount = 0
211- }
212- Update-AzDataTableEntity - Force @TenantsTable - Entity $Tenant
213181 return $ReturnedData
214182 } else {
215183 Write-Error ' Not allowed. You cannot manage your own tenant or tenants not under your scope'
0 commit comments