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)
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
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