How to set monitored servers in maintenance
ON-PREMISES
Applies to Gizmo 2.0
This article describes how to disable the scanning of Exchange servers that will go under maintenance.
Instructions
Copy and save the following script to your Gizmo server:
function Set-GSXServersMaintenance { <# .Description This script allows to set all servers in maintenance. It will process all the server FQDN present in the CSV file and then find the related deployed configuration to disable its scanning. At the end of the mainteinance make sure to run again using the "endMaintenance" parameter. .PARAMETER csvFileName Path to the CSV file containing the servers. Format should be as follow: ServerFQDN, Alias Exchange3.gsxinternal.local, Exchange3 exchange2.gsxinternal.local, exchange2 .PARAMETER templateGuid Determines which configurations should be impacted according to their template GUID. By default 'd854f97f-a776-4a7c-a886-91790c6c3c31' will be used for all Exchange Mailbox Servers. .EXAMPLE PS> Set-GSXServersMaintenance -csvFileName 'servers for maintenance.csv' .EXAMPLE PS> Set-GSXServersMaintenance -csvFileName 'servers for maintenance.csv' .EXAMPLE PS> Set-GSXServersMaintenance -endMaintenance $true .SYNOPSIS Used to disable montoring on server to be put in maintenance. #> param ( [System.String] $csvFileName = 'C:\Users\oraynaut\Desktop\servers for maintenance.csv', [System.String] $templateGuid = 'd854f97f-a776-4a7c-a886-91790c6c3c31', [System.Boolean] $endMaintenance = $false ) # Load GSX commands . "C:\ProgramData\Gsx Solutions\GsxManagementShellLoader.ps1" if ($endMaintenance) { Get-GsxRobotApp | Set-GsxRobotApp -DisableScan $false } else { # Variables $csvServerFQDN = @() #$csvAlias = @() $configGUIDMaintenance = @() # computing where we are, the name of the script, etc. # $scriptExtension = '.ps1' # $scriptFolderMarker = '\' # $folderIndexOf = $PSCommandPath.LastIndexOf($scriptFolderMarker) + 1 # $scriptName = $PSCommandPath.Substring($folderIndexOf, $PSCommandPath.IndexOf($scriptExtension) - $folderIndexOf) # $rootPath = if ($psise) { Split-Path $psise.CurrentFile.FullPath } else { $global:PSScriptRoot } # if (!$rootPath) { $rootPath = ".\" } # Operations $mbxSC = Get-GsxScanConfiguration -TemplateGuid $templateGuid # Read CSV Import-Csv $csvPath | ForEach-Object { $csvServerFQDN += $_."ServerFQDN" #$csvAlias += $_."Alias" } # Iterate through Scan configurations and check if element in CSV foreach ($mailboxConfig in $mbxSC){ $serverFQDN = $mailboxConfig.Parameters["ComputerName"] if ($csvServerFQDN -contains $serverFQDN) { $configGUIDMaintenance += $mailboxConfig.Guid } } # Configurations to put in Maintenance $configGUIDMaintenance # Find RobotApps related to Configurations and put in Maintenance Foreach ($config in $configGUIDMaintenance) { $robotApp = Get-GsxRobotApp -ScanConfigurationGuid $config Write-Host "Setting Robot App '"$robotApp.AppAlias"'in maintenance" -ForegroundColor Yellow $robotApp | Set-GsxRobotApp -DisableScan $true } } }
In order to get started with the script, you need to copy and run the above script which will register the function.
You can do so by just running the content in “PowerShell ISE” or saving the file and running it using “.\scriptname.ps1” (where “scriptname” is the name you use to save the file).You can get additional information on how to use the script using:
Get-Help Set-GsxScanConfiguration -Full
The CSV file can be created using the following example:
ServerFQDN, Alias Exchange3.gsxinternal.local, Exchange3 exchange2.gsxinternal.local, exchange2
After running the script successfully, you should see one verbose line per server set in maintenance:
When the maintenance is over, you must execute the “End Maintenance” by using the following command:Set-GSXServersMaintenance -endMaintenance $true