Auto resolve SCOM alerts


posted by tao.yang
06-02-2009

Downloads: 596
File size: 2.1kB
Views: 4,838

Embed
Auto resolve SCOM alerts
  1. #================================================================================================= 
  2. # AUTHOR:  Tao Yang  
  3. # DATE:    22/12/2008 
  4. # Version: 1.0 
  5. # COMMENT: To be scheduled in Windows scheduler to close any alerts that are more than 7 days old. 
  6. #================================================================================================= 
  7. $CriticalEarlistDate = (Get-Date).adddays(-7) 
  8. $WarningEarlistDate = (Get-Date).adddays(-7) 
  9. $InfoEarlistDate = (Get-Date).adddays(-1) 
  10. $erroractionpreference = "SilentlyContinue" 
  11. $closed = "255" 
  12. ##Initiate SCOM PSSnapin 
  13. $RMS = "<ENTER_ROOT_MANAGEMENT_SERVER_FQDN_HERE>" 
  14. #adding SCOM PSSnapin 
  15. if ((Get-PSSnapin | where-Object { $_.Name -eq 'Microsoft.EnterpriseManagement.OperationsManager.Client' }) -eq $null
  16. {  
  17. Add-PSSnapin Microsoft.EnterpriseManagement.OperationsManager.Client -ErrorAction SilentlyContinue -ErrorVariable Err 
  18. if ((Get-PSDrive | where-Object { $_.Name -eq 'Monitoring' }) -eq $null
  19. New-PSDrive -Name:Monitoring -PSProvider:OperationsManagerMonitoring -Root:\ -ErrorAction SilentlyContinue -ErrorVariable Err | Out-Null 
  20. #Connect to RMS 
  21. Set-Location "OperationsManagerMonitoring::" 
  22. new-managementGroupConnection -ConnectionString:$RMS | Out-Null 
  23. Set-Location Monitoring:\$RMS 
  24.  
  25. #Critical Alerts 
  26. $CriticalAlerts = get-alert -criteria "Severity = '2'"| where { $_.resolutionstate -ne $closed -and $_.timeRaised -le $CriticalEarlistDate
  27. foreach ($alert in $CriticalAlerts
  28. $alert.ResolutionState = $closed 
  29. $alert.update(""
  30. #Warning Alerts 
  31. $WarningAlerts = get-alert -criteria "Severity = '1'" | where { $_.resolutionstate -ne $closed -and $_.timeRaised -le $WarningEarlistDate
  32. foreach ($alert in $WarningAlerts
  33. $alert.ResolutionState = $closed 
  34. $alert.update(""
  35. #Info Alerts 
  36. $InfoAlerts = get-alert -criteria "Severity = '0'" | where { $_.resolutionstate -ne $closed -and $_.timeRaised -le $InfoEarlistDate
  37. foreach ($alert in $InfoAlerts
  38. $alert.ResolutionState = $closed 
  39. $alert.update(""
  40. ##Make sure the script is closed 
  41. if ($error.count -eq "0"
  42. #$host.setShouldExit(0) 
  43. else 
  44. #$host.setShouldExit(1) 

When I was implementing SCOM 2007, I couldn't find a setting in SCOM to auto resolve alerts that are older than certain days. - This functionality is available in MOM 2005. Therefore I wrote this Powershell script and created a Windows scheduled task to run it daily

Concentrated Tech NSoftware Dell Compellent Sponsored by Idera and Concentrated Tech and NSoftware and Dell Compellent
Copyright 2011 PowerShell.com. All rights reserved.