none
auto changing resuotion state

    Question

  • Hi geveryone

    Can anyone help me out here. My purpose is to run a vbs script that change a specific alert from a monitor, from status "new" to status 253.  Below a have a powershell script, but that would not work in the monitor "revovery fied"  this field only accept vbs and js...

    My VBS isn't very strong a have looked at MSFT classes but havent figured it out yet. Below is a powershell that does the trick, but a cannot call this from the recoveryfeild in the monitor. I am running scom 2012.

    regard jimmy

    $resState = 253 # Send Auto Costumer
    $RMS = "xxx.xx.com"

    Add-PSSnapin "Microsoft.EnterpriseManagement.OperationsManager.Client"
    Set-Location "OperationsManagerMonitoring::"
    New-ManagementGroupConnection -ConnectionString:$RMS
    Set-Location $RMS

    $momapi = New-Object -comObject "MOM.ScriptAPI"

    # All yyy alert in 'new' state
    $alerts = Get-Alert | Where-Object {$_.Name -eq "yyyy" -and $_.ResolutionState -eq 0}

    # Change resolution state to "253 # Send Auto Costumer". 
    foreach ($alert in $alerts) {
    # Change resolution
    $alert.ResolutionState = $resState
    # Update the RMS
    $alert.Update("")
    }

    Thursday, July 04, 2013 8:51 PM

Answers

  • hi,

    always change of alert state should not be done from recovery task as recovery task runs on agent and closing alert will not reset monitor state. you need to use notification command notification to achieve this task or connector.

    (or)

    if you are looking to close alert once recovery task as run you can take below approach.

    you can log an event(powershell command :Write-EventLog -ComputerName <RMS server Name > -LogName "Operations Manager" -Source "Health Service Script"  -EntryType information -EventId <custom event id > -Message <ALertID>)  on scom rms server with alert id at the end of your recovery task and create an custom rule as below targeting to RMS server.

    data soured : windows event provider to detect respective event id.

    Action module : run power shell script module : this script need to close alert for alert id and reset monitor state.

    regards


    sridhar v

    Friday, July 05, 2013 7:55 AM
  •  

    Hi,

    Please check if this script works. If so, please refer to it:

    Powershell to change Resolution State in Operations Manager 2012

    http://blog.coretech.dk/kra/powershell-to-change-resolution-state-in-operations-manager-2012/

    Thanks.

    Nicholas Li
    TechNet Community Support

    Friday, July 05, 2013 8:04 AM
    Moderator

All replies

  • hi,

    always change of alert state should not be done from recovery task as recovery task runs on agent and closing alert will not reset monitor state. you need to use notification command notification to achieve this task or connector.

    (or)

    if you are looking to close alert once recovery task as run you can take below approach.

    you can log an event(powershell command :Write-EventLog -ComputerName <RMS server Name > -LogName "Operations Manager" -Source "Health Service Script"  -EntryType information -EventId <custom event id > -Message <ALertID>)  on scom rms server with alert id at the end of your recovery task and create an custom rule as below targeting to RMS server.

    data soured : windows event provider to detect respective event id.

    Action module : run power shell script module : this script need to close alert for alert id and reset monitor state.

    regards


    sridhar v

    Friday, July 05, 2013 7:55 AM
  •  

    Hi,

    Please check if this script works. If so, please refer to it:

    Powershell to change Resolution State in Operations Manager 2012

    http://blog.coretech.dk/kra/powershell-to-change-resolution-state-in-operations-manager-2012/

    Thanks.

    Nicholas Li
    TechNet Community Support

    Friday, July 05, 2013 8:04 AM
    Moderator