You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Get all fallback domains (onmicrosoft.com domains) and check if the DMARC record is set correctly
49
49
try {
50
-
$Domains=New-GraphGetRequest-scope 'https://admin.microsoft.com/.default'-TenantID $Tenant-Uri 'https://admin.microsoft.com/admin/api/Domains/List'|Where-Object-Property Name -like"*.onmicrosoft.com"
50
+
$Domains=New-GraphGetRequest-scope 'https://admin.microsoft.com/.default'-TenantID $Tenant-Uri 'https://admin.microsoft.com/admin/api/Domains/List'|Where-Object-Property Name -Like'*.onmicrosoft.com'
51
51
52
52
$CurrentInfo=$Domains|ForEach-Object {
53
53
# Get current DNS records that matches _dmarc hostname and TXT type
@@ -56,9 +56,9 @@ function Invoke-CIPPStandardAddDMARCToMOERA {
56
56
if ($CurrentRecords.count-eq0) {
57
57
#record not found, return a model with Match set to false
58
58
[PSCustomObject]@{
59
-
DomainName=$_.Name
60
-
Match=$false
61
-
CurrentRecord=$null
59
+
DomainName=$_.Name
60
+
Match=$false
61
+
CurrentRecord=$null
62
62
}
63
63
} else {
64
64
foreach ($CurrentRecordin$CurrentRecords) {
@@ -73,15 +73,15 @@ function Invoke-CIPPStandardAddDMARCToMOERA {
73
73
# Compare the current record with the expected record model
74
74
if (!(Compare-Object-ReferenceObject $RecordModel-DifferenceObject $CurrentRecordModel-Property HostName, TtlValue, Type, Value)) {
75
75
[PSCustomObject]@{
76
-
DomainName=$_.Name
77
-
Match=$true
78
-
CurrentRecord=$CurrentRecord
76
+
DomainName=$_.Name
77
+
Match=$true
78
+
CurrentRecord=$CurrentRecord
79
79
}
80
80
} else {
81
81
[PSCustomObject]@{
82
-
DomainName=$_.Name
83
-
Match=$false
84
-
CurrentRecord=$CurrentRecord
82
+
DomainName=$_.Name
83
+
Match=$false
84
+
CurrentRecord=$CurrentRecord
85
85
}
86
86
}
87
87
}
@@ -92,32 +92,29 @@ function Invoke-CIPPStandardAddDMARCToMOERA {
92
92
} catch {
93
93
if ($_.Exception.Message-like'*403*') {
94
94
$Message="AddDMARCToMOERA: Insufficient permissions. Please ensure the tenant GDAP relationship includes the 'Domain Name Administrator' role: $(Get-NormalizedError-message $_.Exception.message)"
95
-
}
96
-
else {
95
+
} else {
97
96
$Message="Failed to get dns records for MOERA domains: $(Get-NormalizedError-message $_.Exception.message)"
Write-LogMessage-API 'Standards'-tenant $tenant-message "Set DMARC record for domain $($Domain.DomainName)"-sev Info
118
116
}
119
-
}
120
-
catch {
117
+
} catch {
121
118
Write-LogMessage-API 'Standards'-tenant $tenant-message "Failed to set DMARC record for domain $($Domain.DomainName): $(Get-NormalizedError-message $_.Exception.message)"-sev Error
122
119
}
123
120
}
@@ -129,10 +126,10 @@ function Invoke-CIPPStandardAddDMARCToMOERA {
129
126
Write-LogMessage-API 'Standards'-tenant $tenant-message 'DMARC record is already set for all MOERA (onmicrosoft.com) domains.'-sev Info
0 commit comments