Part 2 – PowerShell Monitors – The Modules

Now that we have our script and we are confident that it works, we need to start the process of getting this into SCOM. There are 4 modules types that we will need to put together which are discussed here.

They are:

  1. A probe action which will be our script
  2. A composite data source which will consist of:
    • A data source (scheduler) which will provide the mechanism for determining how often our script will run
    • The probe action (the script)
The PowerShell script

I have created the following folder structure to provide a framework for this walk through. I wouldn’t do it this way in general but it does provide a step by step guide through the process.

Then, right click on the folder FolderMonitoringCountFoldersInFolder and select Add, New Item, PowerShell script file

Name it 1_PScript1.ps1 and click Add

Copy and paste the PowerShell script into the window and save

The Probe

Right click on the folder FolderMonitoringCountFoldersInFolder and select Add, New Item, Empty Management Pack Fragment and call it “_Probe. Copy and paste the following code between the tags.

The key part of the code is as follows:

We are running the PowerShell script and passing in 2 parameters. These are the folder path (top level folder) and also the threshold. The only reason I am passing the threshold in as a parameter is so that the script can output it as a property bag so that we can use it in alert description.

The Composite Data Source

Right click on the folder FolderMonitoringCountFoldersInFolder and select Add, New Item, Empty Management Pack Fragment and call it 3_DS. Copy and paste the following code

Leave a Reply

Your email address will not be published. Required fields are marked *