@@ -27,7 +27,11 @@ Function Invoke-ExecAccessChecks {
27
27
if (! $Results ) {
28
28
$Results = Test-CIPPAccessPermissions - tenantfilter $ENV: TenantID - APIName $APINAME - ExecutingUser $Request.Headers .' x-ms-client-principal'
29
29
} 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
+ }
31
35
}
32
36
} else {
33
37
$Results = Test-CIPPAccessPermissions - tenantfilter $ENV: TenantID - APIName $APINAME - ExecutingUser $Request.Headers .' x-ms-client-principal'
@@ -44,8 +48,8 @@ Function Invoke-ExecAccessChecks {
44
48
TenantId = $Tenant.customerId
45
49
TenantName = $Tenant.displayName
46
50
DefaultDomainName = $Tenant.defaultDomainName
47
- GraphStatus = $null
48
- ExchangeStatus = $null
51
+ GraphStatus = ' Not run yet '
52
+ ExchangeStatus = ' Not run yet '
49
53
GDAPRoles = ' '
50
54
MissingRoles = ' '
51
55
LastRun = ' '
@@ -65,10 +69,14 @@ Function Invoke-ExecAccessChecks {
65
69
$TenantResult
66
70
}
67
71
68
-
69
72
$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
+ }
71
78
} catch {
79
+ Write-Host $_.Exception.Message
72
80
$Results = @ ()
73
81
}
74
82
}
@@ -95,7 +103,11 @@ Function Invoke-ExecAccessChecks {
95
103
if (! $Results ) {
96
104
$Results = Test-CIPPGDAPRelationships
97
105
} 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
+ }
99
111
}
100
112
} else {
101
113
$Results = Test-CIPPGDAPRelationships
0 commit comments