Create Custom Monitors with PowerShell

Sometimes, as a developer, you want to be be able to keep track of free space on a drive, the size of a log, the load on your CPU, the number of users logged in, etc. With PowerShell, it is typically just a matter of finding the right cmdlet amidst the large (and rapidly growing) pool of cmdlets provided by Microsoft and by third parties. Then you just run Get-Foo to check details about the foo resource. And then you come back 5 minutes later and run it again because you want to see how it changes over time.
But wouldn't it be nice if you could just have it run automatically at regular intervals in a separate window that you could just keep in the corner of your screen? Well, I found the barebones of just such a utility sometime ago (authored by Marc van Orsouw,  aka ‘thePowerShellGuy’). His original post is no longer available, but I expanded upon his code and, over time, added features, bug fixes, and enhancements, making it more useful and more user-friendly. Here are a few screenshots of the Monitor Factory in action.
Monitor the size of a database

Start-Monitor -AsJob { 
    Invoke-Sqlcmd 'DBCC SQLPERF(logspace)' | 
    Select-Object 'Database Name','Log Size (MB)','Log Space Used (%)',HasErrors 

Database Size Monitor
Monitor drives on a system
Drive Capacity Monitor
Monitor longest running DB queries
Long-runnning DB Query Monitor
Build Your Own Resource Monitor in a Jiffy reveals how quick and easy it is to get started with the Monitor Factory.

One Response to " Create Custom Monitors with PowerShell "

  1. Alex Innes says:

    Very cool article. Can see using some of this in our environment. Thank you.