Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Database Mail profiles do not allow adding more than one account #9336

Open
danielleshoemake opened this issue Apr 29, 2024 · 0 comments
Open
Labels
bugs life triage required New issue that has not been reviewed by maintainers

Comments

@danielleshoemake
Copy link

danielleshoemake commented Apr 29, 2024

Verified issue does not already exist?

I have searched and found no existing issue

What error did you receive?

WARNING: [22:44:11][New-DbaDbMailProfile] Failure | Violation of UNIQUE KEY constraint
'SYSMAIL_PROFILE_NameMustBeUnique'. Cannot insert duplicate key in object 'dbo.sysmail_profile'. The duplicate key
value is (INGAA LLR Website Email Sender Profile).
The statement has been terminated.

Steps to Reproduce

New-DbaDbMailProfile -SqlInstance localhost -Profile "Test profile" -MailAccountName "Account 1" -MailAccountPriority 1
New-DbaDbMailProfile -SqlInstance localhost -Profile "Test profile" -MailAccountName "Account 2" -MailAccountPriority 2

Upon executing the second command, where the account name and priority has changed, a unique key constraint violation is issued. It seems that there is an attempt to recreate the entire profile versus checking if the profile already exists and then appending an account to the existing profile. It appears that creating the profile and adding an account to the profile are already two separate steps, but the fact that this is a one to many relationship is not accounted for.

Please confirm that you are running the most recent version of dbatools

2.1.3

Other details or mentions

Profiles can have multiple accounts, each is given a priority. The New-DbaDbMailProfile module configures priority, but it seems it only allows adding one account.

What PowerShell host was used when producing this error

Windows PowerShell (powershell.exe)

PowerShell Host Version

Name Value


PSVersion 5.1.17763.3770
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.17763.3770
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1

SQL Server Edition and Build number

Microsoft SQL Server 2019 (RTM) - 15.0.2000.5 (X64) Sep 24 2019 13:48:23 Copyright (C) 2019 Microsoft Corporation Developer Edition (64-bit) on Windows Server 2019 Datacenter 10.0 (Build 17763: ) (Hypervisor)

.NET Framework Version

PSChildName Version


Client 4.8.03761
Full 4.8.03761
Client 4.0.0.0

@danielleshoemake danielleshoemake added bugs life triage required New issue that has not been reviewed by maintainers labels Apr 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugs life triage required New issue that has not been reviewed by maintainers
Projects
None yet
Development

No branches or pull requests

1 participant