Testing out SnapCenter All Hosts Maintenance Scripts

The scripts below are for putting SnapCenter application plugin hosts into maintenance mode and then exiting maintenance mode. This might be useful say if you’re upgrading your SnapCenter server. Everything highlighted needs to be modified accordingly. The scripts could be improved on, here we’re just testing.

Note: These scripts are designed to be run on the SnapCenter server itself (we just specify a credential for ‘open-smconnection’, don’t specify ‘-SMSbaseURL’.)

Script 1) Enter-MaintenanceMode.ps1


import-Module Snapcenter
$SC_admin = "domain\username"
$SVM_Password = ConvertTo-SecureString "user_Password" -AsPlainText -Force
$cred_Admin = New-Object -TypeName System.Management.Automation.PSCredential ($SC_admin, $SVM_Password)

# open connection
open-smconnection -Credential $cred_Admin

# Set all Windows hosts under Maintenance mode
Foreach ($hostname in ((Get-SmHost).Hostname)){set-SmMaintenanceMode -Hostnames $hostname -MaintenanceStatus UnderMaintenance -Confirm:$false}


Script 2) Exit-MaintenanceMode.ps1


import-Module Snapcenter
$SC_admin = "domain\username"
$SVM_Password = ConvertTo-SecureString "user_Password" -AsPlainText -Force
$cred_Admin = New-Object -TypeName System.Management.Automation.PSCredential ($SC_admin, $SVM_Password)

# open connection
open-smconnection -Credential $cred_Admin

# Set all Windows hosts under Maintenance mode
Foreach ($hostname in ((Get-SmHost).Hostname)){set-SmMaintenanceMode -Hostnames $hostname -MaintenanceStatus Production -Confirm:$false}


Testing/Example

The below screenshots show before and after of running the above scripts against a SnapCenter with Microsoft Exchange environment with one DAG and 3 mailbox servers.

Image 1: SnapCenter Managed Hosts before running Enter-MaintenanceMode.ps1

Image 2: SnapCenter Managed Hosts after running Enter-MaintenanceMode.ps1

Notice that the DAG is ‘Suspended’.

Image 3: Checking ‘Details’ for our DAG object in SnapCenter

Notice that – even thought we only see the DAG suspended above – all the mailbox servers are saying “Scheduled jobs for host ... are suspended.”

Image 4: SnapCenter Managed Hosts after running Exit-MaintenanceMode.ps1

To understand the Cmdlet’s check out the ‘SnapCenter Software Cmdlet Reference Guide’.

Comments