-
Notifications
You must be signed in to change notification settings - Fork 0
/
Enable-DKIM.ps1
32 lines (26 loc) · 1.21 KB
/
Enable-DKIM.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
Import-Module ExchangeOnlineManagement
Connect-ExchangeOnline -UserPrincipalName [email protected] -ShowProgress $true
# Specify the custom domain to create the keys for
$Domain = "xbiotech.com"
# Create the keys for the domain
New-DkimSigningConfig -DomainName $Domain -Enabled $false
Write-Host -fore red "selector1._domainkey"
Write-Host -fore red "selector2._domainkey"
Get-DkimSigningConfig -Identity $Domain | Format-List Selector1CNAME, Selector2CNAME
Write-Host -fore red "Now you have to go enter these TXT records in DNS because O365 Powershell blows"
# Some day this section will add the DNS records for you
# But nothing will change the fact that the Exchange servers in O365 will take 9 hours to see those records
#Connect-MsolService
#Get-MsolDomain -DomainName $Domain | select * | fl
$DnsConfigured = $false
While($DnsConfigured -eq $false)
{
$DomainKey = "selector1._domainkey." + $Domain
if(Resolve-DnsName -Name $DomainKey -Type txt | Where-Object {$_.Strings -match "selector1"})
{
Set-DkimSigningConfig -Identity $Domain -Enabled $true
$DnsConfigured = $true
"DNS Resolves finally"
}
}
Get-DkimSigningConfig -Identity $Domain