Skip to content

Commit b32757f

Browse files
committed
better error handling in access check
1 parent b147273 commit b32757f

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/CIPP/Settings/Invoke-ExecAccessChecks.ps1

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Function Invoke-ExecAccessChecks {
2525
if ($Request.Query.SkipCache -ne 'true' -or $Request.Query.SkipCache -ne $true) {
2626
try {
2727
$Cache = Get-CIPPAzDataTableEntity @Table -Filter "RowKey eq 'AccessPermissions' and Timestamp and Timestamp ge datetime'$TimestampFilter'"
28-
$Results = $Cache.Data | ConvertFrom-Json
28+
$Results = $Cache.Data | ConvertFrom-Json -ErrorAction Stop
2929
} catch {
3030
$Results = $null
3131
}
@@ -62,7 +62,7 @@ Function Invoke-ExecAccessChecks {
6262
ExchangeTest = ''
6363
}
6464
if ($TenantCheck) {
65-
$Data = @($TenantCheck.Data | ConvertFrom-Json)
65+
$Data = @($TenantCheck.Data | ConvertFrom-Json -ErrorAction Stop)
6666
$TenantResult.GraphStatus = $Data.GraphStatus
6767
$TenantResult.ExchangeStatus = $Data.ExchangeStatus
6868
$TenantResult.GDAPRoles = $Data.GDAPRoles
@@ -85,7 +85,7 @@ Function Invoke-ExecAccessChecks {
8585
$Results = @()
8686
}
8787
} catch {
88-
Write-Host $_.Exception.Message
88+
Write-Warning "Error running tenant access check - $($_.Exception.Message)"
8989
$Results = @()
9090
}
9191
}
@@ -105,7 +105,7 @@ Function Invoke-ExecAccessChecks {
105105
if (!$Request.Query.SkipCache -eq 'true' -or !$Request.Query.SkipCache -eq $true) {
106106
try {
107107
$Cache = Get-CIPPAzDataTableEntity @Table -Filter "RowKey eq 'GDAPRelationships' and Timestamp ge datetime'$TimestampFilter'"
108-
$Results = $Cache.Data | ConvertFrom-Json
108+
$Results = $Cache.Data | ConvertFrom-Json -ErrorAction Stop
109109
} catch {
110110
$Results = $null
111111
}

0 commit comments

Comments
 (0)