Scripts/IntuneConnectors.ps1
# https://www.petervanderwoude.nl/post/collection-of-information-for-monitoring-the-status-of-connectors-certificates-and-tokens/ $CheckComponent = @() $CheckComponent += "deviceManagement/applePushNotificationCertificate" $CheckComponent += "deviceAppManagement/vppTokens" $CheckComponent += "deviceManagement/depOnboardingSettings" $CheckComponent += "deviceManagement/androidManagedStoreAccountEnterpriseSettings" $CheckComponent += "deviceManagement/windowsAutopilotSettings" $CheckComponent += "deviceManagement/mobileThreatDefenseConnectors" # $CheckComponent += "deviceManagement/exchangeConnectors" $CheckComponent += "deviceAppManagement" $CheckComponent += "deviceManagement/ndesConnectors" $CheckComponent += "deviceManagement/remoteAssistancePartners" $Result = @{} $CheckComponent | ForEach-Object { $uri = "https://graph.microsoft.com/beta/$($_)" $Result.$_ = Invoke-GraphRequest -Uri $uri -SkipHttpErrorCheck } $TempArray = @() ################# Apple ################## $obj = [PSCustomObject]@{ ConnectorName = "Certificate authority connector" TimeStamp = $Result."deviceManagement/ndesConnectors".Value.lastConnectionDateTime Threshold = -1 } $TempArray += $obj $obj = [PSCustomObject]@{ ConnectorName = "APNS expiry date" TimeStamp = $Result."deviceManagement/applePushNotificationCertificate".expirationDateTime Threshold = 30 } $TempArray += $obj $obj = [PSCustomObject]@{ ConnectorName = "VPP last sync date" TimeStamp = $Result."deviceAppManagement/vppTokens".value.lastSyncDateTime Threshold = -1 } $TempArray += $obj $obj = [PSCustomObject]@{ ConnectorName = "VPP expiry date" TimeStamp = $Result."deviceAppManagement/vppTokens".value.expirationDateTime Threshold = 30 } $TempArray += $obj $obj = [PSCustomObject]@{ ConnectorName = "DEP last sync date" TimeStamp = $Result."deviceManagement/depOnboardingSettings".value.lastSuccessfulSyncDateTime Threshold = -1 } $TempArray += $obj $obj = [PSCustomObject]@{ ConnectorName = "DEP expiry date" TimeStamp = $Result."deviceManagement/depOnboardingSettings".value.tokenExpirationDateTime Threshold = 30 } $TempArray += $obj ################# Windows ################## $obj = [PSCustomObject]@{ ConnectorName = "Windows AutoPilot last sync date" TimeStamp = $Result."deviceManagement/windowsAutopilotSettings".lastSyncDateTime Threshold = -1 } $TempArray += $obj if ($Result."deviceAppManagement".isEnabledForMicrosoftStoreForBusiness -eq $true) { $obj = [PSCustomObject]@{ ConnectorName = "Microsoft Store for Business last sync date" TimeStamp = $Result."deviceAppManagement".microsoftStoreForBusinessLastSuccessfulSyncDateTime Threshold = -1 } $TempArray += $obj } ################# Android ################## $obj = [PSCustomObject]@{ ConnectorName = "Managed Google Play App Sync" TimeStamp = $Result."deviceManagement/androidManagedStoreAccountEnterpriseSettings".lastAppSyncDateTime Threshold = -90 } $TempArray += $obj ################# Other ################## $obj = [PSCustomObject]@{ ConnectorName = "Microsoft Defender for Endpoint Connector" TimeStamp = $Result."deviceManagement/mobileThreatDefenseConnectors".value.lastHeartbeatDateTime Threshold = -1 } $TempArray += $obj # $TempArray | Format-Table -AutoSize $Output = @() foreach ($o in $TempArray) { if ($o.TimeStamp) { $ThresholdDate = (Get-Date).AddDays($o.Threshold) if ($ThresholdDate -gt $o.TimeStamp) { $Status = "Warning" } else { $Status = "OK" } $obj = [PSCustomObject]@{ ConnectorName = $o.ConnectorName TimeStamp = (Get-Date $o.TimeStamp -Format "yyyy-MM-dd HH:mm:ss") Threshold = $o.Threshold Expired = (Get-Date $ThresholdDate -Format "yyyy-MM-dd HH:mm:ss") Status = $Status } $Output += $obj } } $Output | Format-Table -AutoSize |