Connect to DB Mirror Failover Partner

Welcome Forums General PowerShell Q&A Connect to DB Mirror Failover Partner

This topic contains 0 replies, has 1 voice, and was last updated by  Forums Archives 7 years ago.

  • Author
  • #6379

    Points: 0
    Rank: Member

    by mg48 at 2013-01-31 12:10:38

    How does Powershell handle connecting to a mirrored failover partner automatically as it will in a .Net program that specifies the failover partner in the connection string?

    by Klaas at 2013-02-01 00:28:02

    I think you should check the status of the databases, the principal will have status 'normal', the mirror is 'restoring'. Of course there's a possibility neither is available.
    If ((Get-Childitem SQLSERVER:SQL\server1\instance1\databases | Where { $ -LIKE 'mirroreddbname'}).status -eq 'Normal') { $instance = "server1\instance1" }
    ElseIf ((Get-Childitem SQLSERVER:SQL\server2\instance2\databases | Where { $ -LIKE 'mirroreddbname'}).status -eq 'Normal') { $instance = "server2\instance2" }
    Else { "None of the instances is available" }
    You can do pretty much the same with SMO instead of the SQL Provider.

    It 's probably even better to check the availability of the server first, to catch any case where the principal is unavailable for other reasons than a failover.

The topic ‘Connect to DB Mirror Failover Partner’ is closed to new replies.