Friday, December 20, 2013

Lightweight monitoring solution with PowerShell

For one of my projects, I needed a simple and lightweight monitoring and testing framework for the public website. As we tweaked SharePoint with some custom redirect functionality to improve SEO, and moved the Google Analytics code from one solution to one other, I wanted to make sure these functionalities still work after each release.
As UI bugs will be noticed directly, those more technical features are hardly noticed directly on failure. So there was the need to script and monitor those features.

As I wanted a simple, free and easy to expand solution (I worked with HostMonitor before, it's easy to write small tests there, but it isn't free), I decided to create my own PowerShell framework. Here it is. It is written for PowerShell 2.0, so webrequests are not executed with Invoke-WebRequest but with the C# System.Net variant.
The script is basically executing tests found in one folder, format the results as HTML and sending it by email with a SMTP server. Things to improve are more test outcomes (now it is Success or Failure, but there might be a yellow inbetween warning or so), or possibly using a tool like Selenium to run tests inside a browser session as well.

No comments: