Removing Databases from Availability Groups with Powershell
Those days at work I had to remove a bunch of databases from the Availability Groups and later drop them from the primary and secondary replicas. I know I could do the click, click and drop thing, but why not PowerShell?
I decided to invest some time, around 10 minutes and create this nice and small fancy script. I hope that you like!
In the script you can see that I am using the switch –WhatIf, just to show what is going to happen with the execution. Also notice the switch –Script in the Remove-SQLAvailabilityDatabase cmdlet, it will script out the removal of the database, but it will not in fact remove it. Testing the script shows a result like this one below.
The script is located at my GitHub account and you can find the link above.
Let me know if you liked or not the solution Feedback is always appreciated.
Data Platform MVP
Posted on February 12, 2018, in Availability Groups, Dicas, GitHub, Powershell, Scripts, VirtualPass and tagged dbatools, powershell, Remove Databases Availability Groups, Removing Databases from AG, Removing Databases from Availability Groups. Bookmark the permalink. Leave a comment.