Posts

Showing posts from August, 2020

Retrieving Database status more than one SQL Server instances

cls $servers = @( "RAMESH" , "RAMESH\TEST" , "RAMESH\UAT" ) $servers | ForEach-Object { $IndServer = $_ $IndServers = New-Object ` -TypeName Microsoft.SqlServer.Management.Smo.Server ` -ArgumentList $IndServer $IndServers . Databases | ForEach-Object { $Status = $_ if ( $Status . Status -ne 'Normal' ) {   Write-Host $IndServer , ',' $Status . Name , ',' $Status . Status -ForegroundColor red } <# else { $Status } #>   } }