Creating database mail with DBA TOOLS powershell script
The below query will configure database profile and account on multiple sql server named instance.
cls
$instanceNames=@("defaultinstance","named\instance1","named\instance2")
$instanceNames|
ForEach-Object{
$InstanceName=$_
New-DbaDbMailAccount `
-SQLinstance $InstanceName `
-Name "DBHealth"`
-DisplayName "AOAG Health Failed" `
-Description "DatbaseHealthCheck" `
-EmailAddress "support@sql.com" `
-ReplyToAddress "support@sql.com" `
-MailServer "mailserveramehere" `
-Force
New-DbaDbMailProfile `
-SqlInstance $InstanceName `
-MailAccountName "DBHealth" `
-Name "DBHealthProfile" `
}
Comments