PowerShell – Checking Status of MSSQL Server Mirrored DB’s

// September 26th, 2012 // Infrastructure

# Load SMO extension
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.Smo") | Out-Null;

# Servers to check
$sqlservers = @("server1", "server2", "server3");
foreach($server in $sqlservers)
     $srv = New-Object "Microsoft.SqlServer.Management.Smo.Server" $server;
     # Get mirrored databases
     $databases = $srv.Databases | Where-Object {$_.IsMirroringEnabled -eq $true};
     Write-Host $server;
     Write-Host "==================================";
     $databases | Select-Object -Property Name, MirroringStatus | Format-Table -AutoSize;
Spread the word

    Joshua Johnson

    Joshua Johnson is a Southern California based IT professional specializing in IT Infrastructure, InfoSec, and fighting entropy.

    More Posts

    Comments are closed.