When you configure DKIM in Office 365 you may notice that some custom domains don’t have DKIM keys saved.
If you run powershell command (Get-DkimSigningConfig) you will notice that many domains will not appear in the list. If you only have one domain then it is not a big deal to create new keys but if you have 100 domains then the process of configuring those keys will be very time consuming. This script will go through all custom domains and create new DKIM signing keys on all those domains that don’t have DKIM keys. Script will also export Selector1CNAME and Selector2CNAME from all domains so that you can easily copy and paste the values in your external DNS. You can run script even if all domains have DKIM keys present.
When you run the script you will be prompted for office 365 credentials.
Script will then check if required module is installed (if not, it will install it) and it will connect to Office 365 and Exchange Online. It will then add all domains that have no DKIM keys to config, if there is any and then export Selector1CNAME and Selector2CNAME values to notepad so that you can easily copy/paste them.
I hope this has been informative for you.