Skip to content

Commit 001f97e

Browse files
committed
fix errors with initial permission data
1 parent f27d1c7 commit 001f97e

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

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

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,11 @@ Function Invoke-ExecAccessChecks {
2727
if (!$Results) {
2828
$Results = Test-CIPPAccessPermissions -tenantfilter $ENV:TenantID -APIName $APINAME -ExecutingUser $Request.Headers.'x-ms-client-principal'
2929
} else {
30-
$LastRun = [DateTime]::SpecifyKind($Cache.Timestamp.DateTime, [DateTimeKind]::Utc)
30+
try {
31+
$LastRun = [DateTime]::SpecifyKind($Cache.Timestamp.DateTime, [DateTimeKind]::Utc)
32+
} catch {
33+
$LastRun = $null
34+
}
3135
}
3236
} else {
3337
$Results = Test-CIPPAccessPermissions -tenantfilter $ENV:TenantID -APIName $APINAME -ExecutingUser $Request.Headers.'x-ms-client-principal'
@@ -44,8 +48,8 @@ Function Invoke-ExecAccessChecks {
4448
TenantId = $Tenant.customerId
4549
TenantName = $Tenant.displayName
4650
DefaultDomainName = $Tenant.defaultDomainName
47-
GraphStatus = $null
48-
ExchangeStatus = $null
51+
GraphStatus = 'Not run yet'
52+
ExchangeStatus = 'Not run yet'
4953
GDAPRoles = ''
5054
MissingRoles = ''
5155
LastRun = ''
@@ -65,10 +69,14 @@ Function Invoke-ExecAccessChecks {
6569
$TenantResult
6670
}
6771

68-
6972
$LastRunTime = $AccessChecks | Sort-Object Timestamp | Select-Object -Property Timestamp -Last 1
70-
$LastRun = [DateTime]::SpecifyKind($LastRunTime.Timestamp.DateTime, [DateTimeKind]::Utc)
73+
try {
74+
$LastRun = [DateTime]::SpecifyKind($LastRunTime.Timestamp.DateTime, [DateTimeKind]::Utc)
75+
} catch {
76+
$LastRun = $null
77+
}
7178
} catch {
79+
Write-Host $_.Exception.Message
7280
$Results = @()
7381
}
7482
}
@@ -95,7 +103,11 @@ Function Invoke-ExecAccessChecks {
95103
if (!$Results) {
96104
$Results = Test-CIPPGDAPRelationships
97105
} else {
98-
$LastRun = [DateTime]::SpecifyKind($Cache.Timestamp.DateTime, [DateTimeKind]::Utc)
106+
try {
107+
$LastRun = [DateTime]::SpecifyKind($Cache.Timestamp.DateTime, [DateTimeKind]::Utc)
108+
} catch {
109+
$LastRun = $null
110+
}
99111
}
100112
} else {
101113
$Results = Test-CIPPGDAPRelationships

0 commit comments

Comments
 (0)