1

#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=10.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91"
$smo = New-Object Microsoft.SqlServer.Management.Smo.Server $env:COMPUTERNAME
$smo.Databases['MyDB'].IsMirroringEnabled

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: , , ,

One Response to "#PSTip Verify if a SQL database is mirrored or not"

Leave a Reply

Submit Comment

© 2016 PowerShell Magazine. All rights reserved. XHTML / CSS Valid.
Proudly designed by Theme Junkie.
%d bloggers like this: