SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Powershell query to get Availability Group Name


Powershell query to get Availability Group Name

Author
Message
jellis 48252
jellis 48252
Valued Member
Valued Member (51 reputation)Valued Member (51 reputation)Valued Member (51 reputation)Valued Member (51 reputation)Valued Member (51 reputation)Valued Member (51 reputation)Valued Member (51 reputation)Valued Member (51 reputation)

Group: General Forum Members
Points: 51 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.
Nick_UK
Nick_UK
SSCommitted
SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)

Group: General Forum Members
Points: 1516 Visits: 1212
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
jellis 48252
jellis 48252
Valued Member
Valued Member (51 reputation)Valued Member (51 reputation)Valued Member (51 reputation)Valued Member (51 reputation)Valued Member (51 reputation)Valued Member (51 reputation)Valued Member (51 reputation)Valued Member (51 reputation)

Group: General Forum Members
Points: 51 Visits: 14
Thank you. I will give this a try.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search