Here is a quick gist which will return the SQL servers responding to the request to the PowerShell host.
As written this needs to be run from PowerShell as a user with privileged sql access to run “select @@servername”. Make sure to target a non system database inside an availability group with read only routing configured. The script can target a named instance by appending the instance name to the $server variable at the top.
The first value returned is the server node responding to regular requests without application intent specified. The second value returned is the server node responding to readonly application intent requests.
0 Comments.