How to auto failover and back by powershell script?

wasabi3689
wasabi3689 used Ask the Experts™
on
I have MSSQL 2016 Always-On availability group. I want to use powershell script to run the failover and fail back from N1 to N1 and from N2 to N1 without using SSMS

How to do that?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
IT Engineer
Distinguished Expert 2017
Commented:
The solution is provided by this MSDN article:
Switch-SqlAvailabilityGroup -Path SQLSERVER:\Sql\SecondaryServer\InstanceName\AvailabilityGroups\MyAg

Open in new window

Vitor MontalvãoIT Engineer
Distinguished Expert 2017

Commented:
Solution provided.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial