Script based Monitor in SCOM2016

Ravi Bhushan 41 Reputation points
2022-07-04T18:14:04.433+00:00

Hi,

I have created a power shell script where it will give output as true if a file exist and False if it does not.
While setting up the monitor for it, I am confused with defining parameter. Also for the Alert Description the output should be the full path of file. Please help me in setting these things.
217426-parameter.jpg

System Center Operations Manager
System Center Operations Manager
A family of System Center products that provide infrastructure monitoring, help ensure the predictable performance and availability of vital applications, and offer comprehensive monitoring for datacenters and cloud, both private and public.
1,608 questions
{count} votes

Accepted answer
  1. SChalakov 10,576 Reputation points MVP Volunteer Moderator
    2022-07-06T08:02:40.66+00:00

    Hi Ravi (@Ravi Bhushan ),

    you need to work with PropertyBags within your script and then use those to configure the Health Expressions (Parameters and Values). I wrote a blog post on integrating a PowerShelll script in SCOM and it contains very detailed explaination, which will help you achieve the goal. Here it is:

    Monitoring Active Directory User Account Expiration using SCOM and PowerShell (Step by Step Guide)

    https://www.pohn.ch/monitor-active-directory-user-account-expiration-using-scom-and-powershell-step-by-step-guide/

    So you need to do the following:

    • get the CookDown PowerShell Management Pack:

    PowerShell Authoring

    https://www.cookdown.com/scom-essentials/powershell-authoring

    Very important: The link also contains a refernce to a video, where you can also get detailed explainations how to use it.

    • The next step will be to edit your script and include the following:

    $ScomAPI = New-Object -ComObject "MOM.ScriptAPI"
    $PropertyBag = $ScomAPI.CreatePropertyBag()

    Afterwards, you need to add Property Bags to your script, like this (example):

    #Prepare API and Property Bag Objects  
    $ScomAPI = New-Object -ComObject "MOM.ScriptAPI"  
    $PropertyBag = $ScomAPI.CreatePropertyBag()  
    
    #check if the dump exists  
    $target_files = Get-ChildItem "D:\temp\Client" -Recurse -Include "*.DMP"  
    
    if ($target_files){      
    $PropertyBag.AddValue("FileExistance","True")      
    } else {      
    $PropertyBag.AddValue("FileExistance","False")  
    }  
    #Return the property bag  
    $PropertyBag  
    
    • Don't forget to add this at the bottom of the script, so that yyou can return the property bag to SCOM: # Return the property bag $PropertyBag
    • Afterwards you can configure the Parameter Names on the wizard like this:

    Healthy Expression:

    Property[@FileExistance] ----- Equals -------- True

    Unhealthy Expression:

    Property[@FileExistance] ----- Equals -------- False

    Please check out the blog I posted, the screenshots and the exaplainations will also help you.

    Last but not least: I noticed that you are trying to monitor for crash dumps (BSODs). You asked a question in the forums a couple fo weeks ago and I posted a late reply to the therad:

    Monitoring for crashdump file in SCOM

    https://learn.microsoft.com/en-us/answers/questions/892413/monitoring-for-crashdump-file-in-scom.html

    As you will read from my reply, there is also a solution for that, developed by a Microsoft MVP (Dujon). Please check it out, it can save you some time.


    (If the reply was helpful please don't forget to upvote or accept as answer, thank you)
    Regards,
    Stoyan

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.