Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Powershell query to get Availability Group Name Expand / Collapse
Author
Message
Posted Tuesday, March 12, 2013 5:03 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Monday, June 17, 2013 9:45 AM
Points: 3, Visits: 14
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.
Post #1430146
Posted Thursday, March 28, 2013 10:58 AM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Wednesday, November 19, 2014 7:59 AM
Points: 1,320, Visits: 1,012
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
Post #1436617
Posted Thursday, March 28, 2013 2:37 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Monday, June 17, 2013 9:45 AM
Points: 3, Visits: 14
Thank you. I will give this a try.
Post #1436744
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse