This discussion has been locked. The information referenced herein may be inaccurate due to age, software updates, or external references.
You can no longer post new replies to this discussion. If you have a similar question you can start a new discussion in this forum.

Unmanaging and suppressing alerts for applications - Scheduled recurring maintenance windows

Here's my take on a recurring, scheduled maintenance window for applications. We've got a hot/cold environment for one of our big in-house applications that rotates every two weeks.

Unmanage:

#Add-Pssnapin swissnapin
Import-Module SwisPowerShell
$start = (Get-Date).ToUniversalTime()
$end = $start.AddDays(14)
$swis = Connect-Swis -Hostname ORIONSERVER -Username username -Password password


$applist = Get-SwisData -SwisConnection $swis -Query @"
SELECT ID
FROM Orion.APM.Application
WHERE Name LIKE '%KEYWORD%'
"@


Foreach( $a in $applist ) {
    $appid = @( $a | ForEach-Object { [string]( $_  ) } )
    Invoke-SwisVerb -SwisConnection $swis -EntityName Orion.APM.Application -Verb Unmanage -Arguments @( "AA:$appid", $start, $end, "false" )
}

Suppress alerts:

#Add-Pssnapin swissnapin
Import-Module SwisPowerShell
$start = (Get-Date).ToUniversalTime()
$end = $start.AddDays(14) #two week release cycle
$swis = Connect-Swis -Hostname ORIONSERVER -Username username -Password password


$apps = Get-SwisData -SwisConnection $swis -Query @"
SELECT Uri
FROM Orion.APM.Application
WHERE Name LIKE '%KEYWORD%'
"@

Foreach( $a in $apps ) {
    $uri = @( $apps | ForEach-Object { [string]( $_  ) } )
    Invoke-SwisVerb -SwisConnection $swis -EntityName Orion.AlertSuppression -Verb SuppressAlerts -Arguments @( $uri, $start, $end )   
}

Just set these Powershell scripts to run on a Scheduled Task and you're all set!

Special thanks to zackmKMSigma​ and aLTeReGo​ for lots of patience while I learn this API thing.