Powershell and SQL Server – 2- List Databases and Mirroring Status from Multiple SQL Server Instance with SMO

The Script will list out all database configured for DBMirroring

$SQLserverDB=@() 
$SQLserverDB=Get-Content "C:\PowershellScript\ServerList.txt"

    foreach($SqlServer in $SQLserverDB)
    {
        Write-Host "Server :"$SqlServer -ForegroundColor Yellow
        $server = New-Object Microsoft.SqlServer.Management.Smo.Server($SqlServer)
        $server.Databases |Where-Object{$_.IsMirroringEnabled -eq 'True'}| select Name, Size, DataSpaceUsage, IndexSpaceUsage, SpaceAvailable,MirroringStatus,IsMirroringEnabled | ft
           
    }

SMO2

Leave a Reply

Your email address will not be published. Required fields are marked *