Skip to content

Instantly share code, notes, and snippets.

@mardahl
Last active December 2, 2020 16:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mardahl/258d14c5dfee0cba5f3bc471d35b762c to your computer and use it in GitHub Desktop.
Save mardahl/258d14c5dfee0cba5f3bc471d35b762c to your computer and use it in GitHub Desktop.
Enable 2048-bit DKIM in Office 365 script
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