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

Get-DbaDbMailServer: Fix e-mail account names if more than one account exists #9506

Merged
merged 1 commit into from
Oct 14, 2024

Conversation

potatoqualitee
Copy link
Member

Redo of this PR with smaller git repo: #9497

Fix an error that results in all account names matching the first account instead of corresponding to real account names.

Type of Change

Purpose

Fix an error that results in all account names matching the first account instead of corresponding to real account names.

Approach

Each corresponding account name is used instead of the only using first account name for all results.

Note: I changed the coding slightly, as it seemed that -Force would keep overwriting the account names. So now it's an array. Please let me know if I need to take a different approach.

@andreasjordan
Copy link
Contributor

I think your solution has kind of the same problem as the old code: There could be different mailservers on different instances all handled in this code. The Account property needs to be from the specific mailserver, that's why the foreach is needed.

$servers | ForEach-Object {
                       $_ | Add-Member -Force -MemberType NoteProperty -Name Account -value $_.Parent.Name
                    }

@potatoqualitee
Copy link
Member Author

but won't -Force just keep overwriting it and you only get the last one? with mine, an array is returned? i suppose i should test this but i got a lot to do 😅

@andreasjordan
Copy link
Contributor

No, -Force is just for the case that the same SMO runs again through this command. In the foreach, every $server is only updated once with the correct value for this $server.

@potatoqualitee
Copy link
Member Author

ty!

@potatoqualitee potatoqualitee merged commit 0c8fbf9 into development Oct 14, 2024
13 checks passed
@potatoqualitee potatoqualitee deleted the redopr branch October 14, 2024 11:34
@andreasjordan
Copy link
Contributor

Now you have merged your version without the foreach. That will not solve the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Get-DbaDbMailServer shows incorrect e-mail account names if more than one account exists.
2 participants