A powershell sample used at a customer for semi-automatically changing the Resolution States:
Import-Module OperationsManager
$Alerts = get-scomalert -ResolutionState 0
if ($Alerts)
{
foreach($Alert in $Alerts)
{
$newState = $null
switch -wildcard ($Alert.Description)
{
"*Active directory*" { $newState = 10 }
"*Exchange*" { $newState = 20 }
"*DNS*" { $newState = 30 }
"*Cisco*" { $newState = 100 }
"*HP*" { $newState = 110 }
"*Printer*" { $newState = 120 }
"*EMC*" { $newState = 130 }
"*RunAs*" { $newState = 200 }
}
switch -wildcard ($Alert.Name)
{
"Cannot start SQL Server Service Broker on Database" { $newState = 40 }
"Machine account policy failure - Active Directory GPO lookup failure" { $newState = 10 }
}
if($newState -ne $null)
{
$Alert.ResolutionState = $newState
$Alert.Update(“Resolution State changed automatically by the notificator”)
}
}
}
And have a great Day
Kåre
This script was just what I was looking for! Works great and works on SCCM 2012. Thanks!
Great example..
Is there a way to change the resolution state based on the MP where the alert came from ?
Thanks!
Thanks MJ
Sure – Have a look at http://www.systemcentercentral.com/opsmgr-2012-which-management-pack-did-this-alert-come-from-via-powershell/
This could easily be implemented in the script.
Have a great day