none
Powershell Monitor

    Question

  • Hello everybody,

    I have a problem with my SCOM 2012 R2.

    I have create a Powershell Monitor with the Help of the "Sample Management Pack".

    The Monitor itself works, I write a log and see that the Monitor runs every 30 seconds on my Testserver.

    But the Alerting is the Problem, I am get no alerts in the Console. If I watch the health Explorer the State won't change.

    Can you help me out with any Ideas?

    If you need more infos please tell me which one you need.

    Thanks in advance

    Example Monitor:

    #Var initialisation
    $state = 'BAD'
    $logfile = "C:\ITSO\TestMonitor.txt"

    #Create SCOM Script api connection
    $api = New-Object -comObject 'MOM.ScriptAPI'

    #Create property bag
    $bag = $api.CreatePropertyBag()

    #Add values to the bag  
    $bag.AddValue('State'.$state)

    $date = date
    "---------------------------" >> $logfile
    $date >> $logfile

    #Return the bag    
    $bag

    Unhealthy Expression

    Property[@Name=’BAD’]



    Thursday, June 14, 2018 9:45 AM

All replies

  • Hi There,

    Use community free PS MP to generate alert using PS script and create 2 state script monitor.

    https://squaredup.com/content/management-packs/free-powershell-management-pack/


    Cheers, Gourav Please remember to mark the replies as answers if it helped.

    Thursday, June 14, 2018 4:24 PM
  • with refer to your provided script, problem come from your unhealthily expression
    Unhealthy Expression
    Property[@Name=’BAD’]
    The corrects ones is
    Parameter Name box: Property[@Name='State'].
    Operator: Equals
    Value: Bad
    roger

    Friday, June 15, 2018 3:51 AM
  • $bag.AddValue('State'.$state) is wrong as well, it should be $bag.AddValue('State',$state)
    Friday, June 15, 2018 7:47 AM
  • $bag.AddValue('State'.$state) is wrong as well, it should be $bag.AddValue('State',$state)

    Good eye ;)

    Cheers


    Sam (Please take a moment to "Vote as Helpful" and/or "Mark as Answer" wherever applicable. Thanks!) Blog:AnalyticOps Insights Twitter:Sameer Mhaisekar

    Friday, June 15, 2018 8:31 AM
  • Hello and many thanks for the answers.

    Now it works! :-)

    Thanks again and regards.

    Simon

    Monday, June 18, 2018 6:49 AM