Archive for January 2012

Check Mirroring Status with Powershell

Here’s a simple Powershell snippet to check the mirroring status on your SQL Server instances. ?View Code POWERSHELL# 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 […]

Get-ServerErrors Powershell Function

Here’s a little Powershell function I’m using to check the Event Logs and SQL Server Error Logs in one easy swoop; ?View Code POWERSHELLfunction Get-ServerErrors { # Server to check & hours back. Will only support default sql instances # Could add a third param for instance and modify script where appropriate if needed param ($server, […]