Monitor Everything with Monitis – And do it easily with PowerShell – Part 14 (Final)

Scheduling Custom Monitors with Monitis and PowerShell

In last article, we talked about creating custom monitor updater commands that would run a script and upload the values to Monitis.  These custom updaters make it a snap to convert any PowerShell script to a Monitis monitor.  Simply plug the script in and start using it’s more logical name: Update-YourMonitor.

Add-MonitisCustomMonitorUpdater -Name OutOfPaper -ScriptBlock {
    Get-Counter "\Print Queue(*)\Out of Paper Errors" | 
        Select-Object -ExpandProperty CounterSamples | 
        Where-Object { $_.InstanceName -ne '_total' -and $_.CookedValue -gt 0} |
        Select-Object @{
            Label = "Printer"
        }, @{
            Label = "OutOfPaperErrors"
} -Property Printer, OutOfPaperErrors


Once you’ve run this code, you can simply do:

Import-Module Monitis

To update the values.

You can simply schedule the update by scheduling the two lines.  To click thru it, run TaskSched.msc, then create a new task.  Run PowerShell.exe as the task, and use the arguments –command Import-Module Monitis;Update-MonitisOutOfPaper.

You can also schedule the task using a script, but not one built into the box.

All throughout this article series, you’ve been focused on using the Monitis module and in-the-box capabilities of Powershell, but there are hundreds of community modules to choose from.  You can easily leverage these community modules in your own custom monitors.

In one very large collection of these modules, called the PowerShellPack (, there is a task scheduler module you can use to schedule the monitor.

Like every command in PowerShell and every command in the monitis module, you can find out about the commands in this module with Get-Command and Get-Help.

If you want to schedule a task that runs your custom monitor with this module, it will look something like this:

New-Task |
    Add-TaskTrigger -OnBoot -Repeat "0:0:10" |
    Add-TaskAction -Script {
        Import-Module Monitis
    } | 
    Register-ScheduledTask -name "CheckForOutOfPaper" -Credential (Get-Credential)

Register-ScheduledTask -name “CheckForOutOfPaper” -Credential (Get-Credential)

New task creates a new task

Add-TaskTrigger gives it a new trigger, on boot and repeating every 10 minutes thereafter.

Add-TaskAction runs the monitor, importing the module and running Update-OutOfPapeer.

Register-ScheduledTask registers the task, and –Credential registers the credential the task will be run under.

That’s it.  Now you can create a monitor to hold any piece of information, collect that information with PowerShell, and update it on a regular basis.  Thanks to your notification rule, your printer lackey will automatically head off to keep your printers filled, and you can monitor your friends Facebook updates while Monitis and PowerShell monitor your data center.

Monitis is an incredible monitoring platform with the flexibility to monitor whatever you want.  PowerShell is an incredible task management and automation platform that can do anything you need it to.  Together, you truly can Monitis anything with Monitis.

See also:

Monitor Everything with Monitis – And do it easily with PowerShell – Part 1

Part 2: Managing External Monitors with Monitis and PowerShell

Part 3: Mining External Monitor Results with Monitis and PowerShell

Part 4: Monitoring Web Applications with Monitis

Part 5: Testing Web Content with Monitis, Excel, and PowerShell

Part 6: Monitoring Anything with a Custom Monitor

Part 7:  Hardware Inventory with Monitis Custom Monitors

Part 8: Monitoring Logons with Monitis

Part 9: Monitoring Connections to Shared Folders with Monitis and Custom Monitors

Part 10: Inventory Windows Installations with Monitis and PowerShell

Part 11: Monitoring Removable Disks on Many Computers with Monitis and PowerShell

Part 12: Monitoring Event Logs and Using Monitis Notifications

Part 13: Monitoring out of Paper with Monitis (Printer Monitoring)