Last active
December 2, 2020 16:40
-
-
Save mardahl/258d14c5dfee0cba5f3bc471d35b762c to your computer and use it in GitHub Desktop.
Enable 2048-bit DKIM in Office 365 script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
try{ | |
Connect-ExchangeOnline -ErrorAction Stop | |
} catch { | |
Throw "Failed to logon to Exchange Online" | |
} | |
$dkim = Get-DkimSigningConfig | |
foreach($obj in $dkim){ | |
Write-Host "Enabling 2048-bit DKIM for $($obj.Domain)" -ForegroundColor Green | |
Write-Verbose "Enable - DKIM" -Verbose | |
Set-DkimSigningConfig -Identity $($obj.Domain) -Enabled $true | |
if($obj.Enabled){ | |
Write-Verbose "Rotating key to 2048-bit" -Verbose | |
Rotate-DkimSigningConfig -KeySize 2048 -Identity $($obj.Domain) | |
} | |
Write-Output " " | |
pause | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment