#PSTip Verify if a SQL database is mirrored or not

Note: This tip requires PowerShell 2.0 or above.

When using SQL SMO to work with mirroring configuration, it is essential to verify if the database is mirrored, or not, before performing any other operations. In today’s tip, we shall see how to use SQL SMO in PowerShell to achieve this.

Add-Type -AssemblyName "Microsoft.SqlServer.Smo, Version=, Culture=neutral, PublicKeyToken=89845dcd8080cc91"
$smo = New-Object Microsoft.SqlServer.Management.Smo.Server $env:COMPUTERNAME

The IsMirroringEnabled property returns a boolean value that specifies whether mirroring is enabled on the database. If True, the database has mirroring enabled. Otherwise, False is returned.

Filed in: Columns, Tips and Tricks Tags: , , ,
© 2018 PowerShell Magazine. All rights reserved. XHTML / CSS Valid.
Proudly designed by Theme Junkie.
%d bloggers like this: