Fix Enrollment Date Null Handling
diff --git a/Get-IntuneUpdateDeviceInfo.ps1 b/Get-IntuneUpdateDeviceInfo.ps1 index 8adde97..8183a9e 100644 --- a/Get-IntuneUpdateDeviceInfo.ps1 +++ b/Get-IntuneUpdateDeviceInfo.ps1
@@ -347,7 +347,13 @@ else { Write-Output "`tEnrolled for:" foreach ($key in $response.enrollment.Keys){ - Write-Output "`t`t$key : $($response.enrollment[$key].enrollmentState) ($($($response.enrollment[$key].lastModifiedDateTime?.ToString("dddd, MMMM dd, yyyy"))))" + $lastModified = if ($response.enrollment[$key].lastModifiedDateTime) { + $response.enrollment[$key].lastModifiedDateTime.ToString("dddd, MMMM dd, yyyy") + } else { + "N/A" + } + + Write-Output "`t`t$key : $($response.enrollment[$key].enrollmentState) ($lastModified)" } } } @@ -721,4 +727,4 @@ } } -} \ No newline at end of file +}