Thursday 7 February 2019

PSScript:- Modify database mail Account

The below script was developed to modify existing DBMail account with new details like a new smtp server, authentication details etc, The below script was developed for specific requirement but will give you a template on how to make the changes via Powershell.



Copyright © 2019 Vinoth N Manoharan.The information provided in this post is provided "as is" with no implied warranties or guarantees.

Tuesday 5 February 2019

DBMail - Set mail server login password failed

Recently one of my clients complained that they were not able to modify DB mail setting and it is failing with the following error,

set mail server password failed for Mail Server '<servername>'

An error occured during Service Master Key decryption(Microsoft SQL Server, Error:33094)


This error happen when the service account is not able to decrypt the Service Master key may the server was rebuilt or migrated, or simply the process dencrypting  does not use the latest key. The only way to resolve this issue is by regenerating the Service Master Key.

https://technet.microsoft.com/en-us/library/ms187788.aspx

The REGENERATE phrase regenerates the service master key. When the service master key is regenerated, SQL Server decrypts all the keys that have been encrypted with it, and then encrypts them with the new service master key. This is a resource-intensive operation. You should schedule this operation during a period of low demand, unless the key has been compromised. If any one of the decryptions fail, the whole statement fails.

The FORCE option causes the key regeneration process to continue even if the process cannot retrieve the current master key, or cannot decrypt all the private keys that are encrypted with it. Use FORCE only if regeneration fails and you cannot restore the service master key by using the RESTORE SERVICE MASTER KEY statement.”

Once I ran ALTER SERVICE MASTER KEY FORCE REGENERATE the DBMail started working without any issues.