Skip to content

Commit 6a73bea

Browse files
committed
Error handling on tenant group updates
1 parent 3433d05 commit 6a73bea

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

Modules/CIPPCore/Public/TenantGroups/Update-CIPPDynamicTenantGroups.ps1

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -103,14 +103,18 @@ function Update-CIPPDynamicTenantGroups {
103103
$LicenseInfo = $SkuHashtable[$_.customerId]
104104
} else {
105105
Write-Information "Fetching licenses for tenant $($_.defaultDomainName)"
106-
$LicenseInfo = New-GraphGetRequest -uri 'https://graph.microsoft.com/v1.0/subscribedSkus' -TenantId $_.defaultDomainName
107-
# Cache the result
108-
$CacheEntity = @{
109-
PartitionKey = 'sku'
110-
RowKey = [string]$_.customerId
111-
JSON = [string]($LicenseInfo | ConvertTo-Json -Depth 5 -Compress)
106+
try {
107+
$LicenseInfo = New-GraphGetRequest -uri 'https://graph.microsoft.com/v1.0/subscribedSkus' -TenantId $_.defaultDomainName
108+
# Cache the result
109+
$CacheEntity = @{
110+
PartitionKey = 'sku'
111+
RowKey = [string]$_.customerId
112+
JSON = [string]($LicenseInfo | ConvertTo-Json -Depth 5 -Compress)
113+
}
114+
Add-CIPPAzDataTableEntity @LicenseCacheTable -Entity $CacheEntity -Force
115+
} catch {
116+
Write-LogMessage -API 'TenantGroups' -message 'Error getting licenses' -Tenant $_.defaultDomainName -sev Warning -LogData (Get-CippExeception -Exception $_)
112117
}
113-
Add-CIPPAzDataTableEntity @LicenseCacheTable -Entity $CacheEntity -Force
114118
}
115119
}
116120
$SKUId = $LicenseInfo.SKUId ?? @()

0 commit comments

Comments
 (0)