@@ -39,31 +39,33 @@ function Push-DomainAnalyserDomain {
3939 }
4040
4141 $Result = [PSCustomObject ]@ {
42- Tenant = $Tenant.Tenant
43- TenantID = $Tenant.TenantGUID
44- GUID = $ ($Domain.Replace (' .' , ' ' ))
45- LastRefresh = $ (Get-Date (Get-Date ).ToUniversalTime() - UFormat ' +%Y-%m-%dT%H:%M:%S.000Z' )
46- Domain = $Domain
47- NSRecords = (Read-NSRecord - Domain $Domain ).Records
48- ExpectedSPFRecord = ' '
49- ActualSPFRecord = ' '
50- SPFPassAll = ' '
51- ActualMXRecords = ' '
52- MXPassTest = ' '
53- DMARCPresent = ' '
54- DMARCFullPolicy = ' '
55- DMARCActionPolicy = ' '
56- DMARCReportingActive = ' '
57- DMARCPercentagePass = ' '
58- DNSSECPresent = ' '
59- MailProvider = ' '
60- DKIMEnabled = ' '
61- DKIMRecords = ' '
62- MSCNAMEDKIMSelectors = ' '
63- Score = ' '
64- MaximumScore = 160
65- ScorePercentage = ' '
66- ScoreExplanation = ' '
42+ Tenant = $Tenant.Tenant
43+ TenantID = $Tenant.TenantGUID
44+ GUID = $ ($Domain.Replace (' .' , ' ' ))
45+ LastRefresh = $ (Get-Date (Get-Date ).ToUniversalTime() - UFormat ' +%Y-%m-%dT%H:%M:%S.000Z' )
46+ Domain = $Domain
47+ NSRecords = (Read-NSRecord - Domain $Domain ).Records
48+ ExpectedSPFRecord = ' '
49+ ActualSPFRecord = ' '
50+ SPFPassAll = ' '
51+ ActualMXRecords = ' '
52+ MXPassTest = ' '
53+ DMARCPresent = ' '
54+ DMARCFullPolicy = ' '
55+ DMARCActionPolicy = ' '
56+ DMARCReportingActive = ' '
57+ DMARCPercentagePass = ' '
58+ DNSSECPresent = ' '
59+ MailProvider = ' '
60+ DKIMEnabled = ' '
61+ DKIMRecords = ' '
62+ MSCNAMEDKIMSelectors = ' '
63+ EnterpriseEnrollment = ' '
64+ EnterpriseRegistration = ' '
65+ Score = ' '
66+ MaximumScore = 160
67+ ScorePercentage = ' '
68+ ScoreExplanation = ' '
6769 }
6870
6971 $Scores = [PSCustomObject ]@ {
@@ -246,6 +248,51 @@ function Push-DomainAnalyserDomain {
246248 }
247249 # EndRegion DKIM Check
248250
251+ # Region Intune Enrollment CNAME Check
252+ try {
253+ # Check enterpriseenrollment CNAME
254+ $EnrollmentResult = Resolve-DnsHttpsQuery - Domain " enterpriseenrollment.$Domain " - RecordType CNAME
255+ if ($EnrollmentResult.Answer ) {
256+ $EnrollmentCNAME = ($EnrollmentResult.Answer | Where-Object { $_.type -eq 5 }).data -replace ' \.$'
257+ if ($EnrollmentCNAME -eq ' enterpriseenrollment-s.manage.microsoft.com' ) {
258+ $Result.EnterpriseEnrollment = ' Correct'
259+ } elseif ($EnrollmentCNAME -eq ' enterpriseenrollment.manage.microsoft.com' ) {
260+ $Result.EnterpriseEnrollment = ' Legacy'
261+ $ScoreExplanation.Add (' Enterprise Enrollment CNAME points to legacy endpoint (enterpriseenrollment.manage.microsoft.com)' ) | Out-Null
262+ } else {
263+ $Result.EnterpriseEnrollment = " Unexpected: $EnrollmentCNAME "
264+ $ScoreExplanation.Add (' Enterprise Enrollment CNAME points to unexpected target' ) | Out-Null
265+ }
266+ } else {
267+ $Result.EnterpriseEnrollment = ' No CNAME'
268+ $ScoreExplanation.Add (' No Enterprise Enrollment CNAME record found' ) | Out-Null
269+ }
270+ } catch {
271+ $Result.EnterpriseEnrollment = ' Error'
272+ Write-LogMessage - API ' DomainAnalyser' - tenant $DomainObject.TenantId - message " Enterprise Enrollment CNAME error for $Domain " - LogData (Get-CippException - Exception $_ ) - sev Error
273+ }
274+
275+ try {
276+ # Check enterpriseregistration CNAME
277+ $RegistrationResult = Resolve-DnsHttpsQuery - Domain " enterpriseregistration.$Domain " - RecordType CNAME
278+ if ($RegistrationResult.Answer ) {
279+ $RegistrationCNAME = ($RegistrationResult.Answer | Where-Object { $_.type -eq 5 }).data -replace ' \.$'
280+ if ($RegistrationCNAME -eq ' enterpriseregistration.windows.net' ) {
281+ $Result.EnterpriseRegistration = ' Correct'
282+ } else {
283+ $Result.EnterpriseRegistration = " Unexpected: $RegistrationCNAME "
284+ $ScoreExplanation.Add (' Enterprise Registration CNAME points to unexpected target' ) | Out-Null
285+ }
286+ } else {
287+ $Result.EnterpriseRegistration = ' No CNAME'
288+ $ScoreExplanation.Add (' No Enterprise Registration CNAME record found' ) | Out-Null
289+ }
290+ } catch {
291+ $Result.EnterpriseRegistration = ' Error'
292+ Write-LogMessage - API ' DomainAnalyser' - tenant $DomainObject.TenantId - message " Enterprise Registration CNAME error for $Domain " - LogData (Get-CippException - Exception $_ ) - sev Error
293+ }
294+ # EndRegion Intune Enrollment CNAME Check
295+
249296 # Region MSCNAME DKIM Records
250297 # Get Microsoft DKIM CNAME selector Records
251298 # Ugly, but i needed to create a scope/loop i could break out of without breaking the rest of the function
0 commit comments