SQL Database Mirroring using Powershell

I’m searching for a PowerShell script that will automate SQL database mirroring. Michael J. Messano created a nice script years ago but we wanted to get away from using SMO from SQL 2012 R2. I’m not having any luck Googling it. My apologies if this subject has already come up, I’m new here. If it has, just point me in that direction. :slight_smile: Thanks

What about this: https://blogs.msdn.microsoft.com/sqlalwayson/2012/02/03/configuring-alwayson-with-sql-server-powershell/

The configuration we’re attempting is a networked SQL 2016 standalone server mirroring to another networked SQL 2016 standalone server without clustering. Setting this up manually using SSMS 2016 causes headaches due to some GUI issues in SSMS 2016. However, using SSMS 2012/2014 to configure mirroring on a SQL 2016 box works like a charm. So we figured we’d try to script it without using SMO. Seems to be a difficult task so far. :slight_smile:

https://superwidgets.wordpress.com/2016/02/17/setting-up-certificate-based-communication-between-sql-server-endpoints-for-sql-mirroring/