Skip to main content

Posts

Showing posts from February, 2019

SQL Diagnostics Manager - Script to Disable Maintenance Mode on All Servers

We use Idera's SQL Diagnostics Manager and there is a defect where monitored servers are sometimes not taken out of maintenance mode as specified by the schedule. As a workaround, I wrote the following script that runs each morning to log which servers are in maintenance mode, and disables maintenance mode on all servers. The use of the -MMRecurring switch on Set-SQLdmMonitoredInstance disables maintenance mode and keeps the maintenance mode schedule enabled. add-pssnapin sqldmsnapin $LogFile = "D:\Jobs\DisableMaintenanceModeAll\MMEnabledLog.txt" # Log any servers that are currently in maintenance mode $MMEnabled = invoke-sqlcmd -serverinstance -Query "USE SQLdmRepository; SELECT InstanceName FROM MonitoredSQLServers WHERE MaintenanceModeEnabled = 1" if( $MMEnabled.ItemArray.Count -gt 0 ) { add-content -Value " " -path $LogFile add-content -Value "================================================" -path $LogFile add-content -Value &qu