dbatools icon indicating copy to clipboard operation
dbatools copied to clipboard

Get-DbaAgReplica return the role of the nodes unknown if you pass the secondary node to it

Open alihex opened this issue 2 years ago • 1 comments

Verified issue does not already exist?

I have searched and found no existing issue

What error did you receive?

The logic of the output is not correct.

Steps to Reproduce

Get-DbaAgReplica -sqlinstance $ServerInstance

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

Name : dbatools Path : C:\Program Files\WindowsPowerShell\Modules\dbatools\1.1.145\dbatools.psm1 Description : The community module that enables SQL Server Pros to automate database development and server administration ModuleType : Script Version : 1.1.145 NestedModules : {Bogus, System.Net.Http, Microsoft.Data.SqlClient, Microsoft.SqlServer.Smo...} ExportedFunctions : {Add-DbaAgDatabase, Add-DbaAgListener, Add-DbaAgReplica, Add-DbaComputerCertificate...} ExportedCmdlets : {Select-DbaObject, Set-DbatoolsConfig} ExportedVariables : ExportedAliases : {Attach-DbaDatabase, Detach-DbaDatabase, Get-DbaBuildReference, Get-DbaDbModule...}

Other details or mentions

image

What PowerShell host was used when producing this error

Windows PowerShell (powershell.exe)

PowerShell Host Version

PSVersion : 5.1.14393.6343

SQL Server Edition and Build number

Microsoft SQL Server 2019 (RTM-CU22-GDR) (KB5029378)

.NET Framework Version

PSChildName Version


v2.0.50727 2.0.50727.4927 v3.0 3.0.30729.4926 Windows Foundation 3.0.4506.4926 Windows Presentation 3.0.6920.4902 Foundation
v3.5 3.5.30729.4926 Client 4.8.03761
Full 4.8.03761

alihex avatar Dec 12 '23 21:12 alihex

To get the correct data, ask the primary, not the secondary. Inside of the command, we do nothing with that data, we just return what the SMO tells us. I think this is by design, but I'm not 100% sure on this.

andreasjordan avatar Dec 28 '23 14:12 andreasjordan