Powershell query to get Availability Group Name

  • Hi,

    I am building a powershell script that has a GUI interface for a 2008R2 cluster with SQL 2012 AlwaysOn Availability Groups. I am at the last stage where I am trying to build out the script to force the manual failover to a third node at a remote site and I am having a difficult time via either powershell or T-SQL building a query that will return just the Availability Group name that I could use with the Switch-AvailabilityGroup command.

    Would someone have some insight on how I might accomplish this?

    Thank you.

  • you could try using the below adding your server name into the variable

    $Server = "SERVERNAME"

    Set-Location SQLSERVER:\SQL\$Server\DEFAULT\AvailabilityGroups(get-childitem).Name

  • Thank you. I will give this a try.

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply