Windows Server Status Monitor v1.6

I wanted to create a lightweight and easy to setup server status monitor. It needed to highlight any metrics that were outside of a customisable threshold visually and be able to e-mail the report or run continuously. Based on a script from Bhavik Solanki (on TechNet) and with some help from my good friend, and software developer Dan Price, we created WinServ-Status, now known as Windows Server Status Monitor.

This utility is available to download from the Microsoft TechNet GalleryPowerShell Gallery and GitHub.

-Mike

Twitter – @Digressive

 

Features and Requirements

  • The utility will display the server name, uptime, CPU, memory and storage information, online status.
  • The utility can be configured with a customisable alerts for the CPU, memory and storage.
  • The utility can display the results as either a CSV file or a HTML file.
  • The utility can be configured to monitor continuously, or run once.
  • The utility can be configured to e-mail the results.

The utility has been tested running on Windows 10 and Windows Server 2016, monitoring PCs and Servers running Windows 10, Windows Server 2016, Windows Server 2012 R2, and Windows Server 2008 R2. The utility must be run as a user with administrator-level privileges to the systems it is monitoring.

 

Generating A Password File

The password used for SMTP server authentication must be in an encrypted text file. To generate the password file, run the following command in PowerShell, on the computer that is going to run the script and logged in with the user that will be running the script. When you run the command you will be prompted for a username and password. Enter the username and password you want to use to authenticate to your SMTP server.

Please note: This is only required if you need to authenticate to the SMTP server when send the log via e-mail.

$creds = Get-Credential
$creds.Password | ConvertFrom-SecureString | Set-Content c:\scripts\ps-script-pwd.txt

After running the commands, you will have a text file containing the encrypted password. When configuring the -Pwd switch enter the path and file name of this file.

 

Configuration

The table below shows all the command line options available with descriptions and example configurations.

Command Line Switch Mandatory Description Example
-List Yes The TXT file containing the netbios names of the servers you wish to check. C:\foo\Servers.txt
-O Yes The location to output the HTML or CSV results file. C:\foo
-CpuAlert No The minimum percentage of CPU usage that should trigger an alert. 95
-DiskAlert No The minimum percentage of any disk usage that should trigger an alert. 85
-MemAlert No The minimum percentage of memory usage that should trigger an alert. 90
-Refresh No The number of seconds the script should wait before refreshing the results.

The minimum refresh period is 300 seconds (5 minutes) and the maximum is 28800 (8 hours).

600
-Light No Configure the HTML results file to have a light theme. N/A
-Csv No Export a CSV file, instead of a HTML file. N/A
-SendTo No The email address to send the log file to. me@contoso.com
-From No* The email address that the log file should be sent from.

*This switch isn’t mandatory but is required if you wish to email the log file.

example@contoso.com
-Smtp No* SMTP server address to use for the email functionality.

*This switch isn’t mandatory but is required if you wish to email the log file.

mail01.contoso.com

OR

smtp.live.com

OR

smtp.office365.com

-User No* The username of the account to use for SMTP authentication.

*This switch isn’t mandatory but may be required depending on the configuration of the SMTP server.

example@contoso.com
-Pwd No* The location of the file containing the encrypted password of the account to use for SMTP authentication.

*This switch isn’t mandatory but may be required depending on your SMTP server.

c:\foo\ps-script-pwd.txt
-UseSsl No* Add this option if you wish to use SSL with the configured SMTP server.

Tip: If you wish to send email to outlook.com or office365.com you will need this.

*This switch isn’t mandatory but may be required depending on the configuration of the SMTP server.

N/A

 

Change Log

2019-02-23 Version 1.6

  • Updated the style of the web page with a cleaner look.
  • Added ‘online’ CSS animation when the web page is in monitor mode – this is configured by using the refresh switch. It will not display when in report mode (no refresh switch).

2018-06-10 Version 1.5

  • Added light theme for the web page.
  • Added ability to export a CSV file instead of a web page.
  • Improved the Offline visual effect on the web page.

2018-05-24 Version 1.4

  • Servers are now sorted alphabetically, regardless of how they are entered in the text file.
  • Offline servers are automatically shuffled to the top of the report.
  • Added validation for the command line parameters.
  • Removed IP addresses, and table headers to make room for more information.
  • Due to removing table headers, added component name to CPU and RAM usage columns.
  • Added new effect using css animation for offline servers.
  • Added different shade of black for alternate table rows.

2017-10-16 Version 1.3

  • Changed SMTP authentication to require an encrypted password file.
  • Added instructions on how to generate an encrypted password file.

2017-10-09 Version 1.2

  • Added necessary information to add the script to the PowerShell Gallery.

2018-09-27 Version 1.1

  • Added capability for the script to run and monitor server status continuously.
  • Added icons to warning and error states to assist in at-a-glace reporting.
  • Added memory and CPU usage.
  • Added warning thresholds for memory and CPU usage.
  • Changed disk usage reporting from “percent free” to actual disk usage to match the added CPU and memory usage.
  • Changed the warning threshold to of disk usage to match the change.
  • Changed the visual style of the report.
  • Changed visual style of warnings and errors.
  • Changed code formatting for readability.

2017-07-28 Version 1.0

  • First public release.

 

PowerShell Code

Normally I’d put the powershell code here, but due to the amount of HTML in this one it doesn’t play well with the blog.

You can see the code and obtain the script from the links at the top of this post.

19 Comments Add yours

  1. Meer says:

    Hi Mike .. really nice script …just have one question here ..how can i schedule this script to run every 8 hour

    Like

    1. Mike Galvin says:

      Hi Meer,

      Please disregard my previous reply, I was under the impression you were asking about the Hyper-V-Backup script.

      For the WinServStatus script to refresh every 8 hours, you should be able to set the refresh option to -Refresh 28800

      -Mike

      Like

  2. Senthil Rajna says:

    Hi Mike, while I run the script I can see the output has Offline, do I missing anything?

    Like

    1. Mike Galvin says:

      Hi Senthil,

      You might need to check your account privileges, or it could be the network access on the computer running the script, and if it has access to the servers in the list to check. Without more info, it can be difficult to be sure

      -Mike

      Like

  3. Jeferson says:

    Amazing script thank you so much . I don’t know if possible but I would like save too into a csv or txt file . Thank you

    Like

    1. Mike Galvin says:

      Hi Jeferson,

      Thank you for the kind words, I’m glad you like it. I’m sure it’s possible to export the info into a CSV or TXT file with some changes, however it’s not something I’m looking into right now. I’m happy for anyone to take the code and change it for their needs though.

      -Mike

      Like

  4. Prabhakar says:

    hi Mike,

    Thanks for sharing script i have run the script in power shell but showing serverfile & output path in powershell . please guide how & where to add entry serverfile & outputpath in power shell.
    PS C:\foo> C:\foo\WinServ-Status.ps1
    cmdlet WinServ-Status.ps1 at command pipeline position 1
    Supply values for the following parameters:
    ServerFile: c:\foo\servers.txt
    OutputPath: c:\foo

    Like

    1. Mike Galvin says:

      Hi Parbhakar,

      Apologies for the late reply, I only just noticed this comment. To run the monitor, you’ll need to run this command with the path to your own files:

      PowerShell -ExecutionPolicy Bypass -File [PATH-TO-SCRIPT]WinServ-Status.ps1 -List [PATH-TO-SERVER-LIST]servers.txt -O [PATH-TO-OUTPUT-FILE -DiskAlert 90 -CpuAlert 95 -MemAlert 95

      -Mike

      Like

  5. Jasper says:

    Hi Mike,

    Really like the script, nice job! I was wondering though, how could I go about adding a ‘description’ column in the output for each of the servers that are imported through the .txt file? Like it would be really nice if next to each $ServerName in the output it could have a column next to it saying what that server is being used for. (Example Output: Svrhostname1 | Main Apache Server | CPU usage | Ram Usage | etc. the rest of the already existing columns). This would be regardless if the server was up or down. Any assistance or suggestions would be greatly appreciated.

    Like

    1. Mike Galvin says:

      Hi Jasper,

      Thanks for the kind words, I’m glad the script has been useful to you. To add a description of the servers would require some work to the script. Currently it take the names of the servers in a simple TXT file and then generates all the displayed information from that. To display a user added description could be done with using a CSV file of server names along with a second field of descriptions and then the script would display the name, description and then all the other information.

      Another way of doing it would be to have the descriptions of the servers in the Computer description field in the Computer Name section of the System Info and then get that from WMI, if it’s available there.

      So there’s two ways of doing it that I can think of. I like the idea of doing it, I may add this as an option to a future version of the script when I get time to work on them again.

      Thanks for the comment.

      -Mike

      Like

  6. Phil says:

    I love the script and what it can do. Is there a way to display not only the servername but also a description. So if in the txt file I have server abc123 – Application Server. Is there a way that I can get the output to html to also display server abc123 – Application Server. This way when others look at the results they know what each server does.

    Like

    1. Mike Galvin says:

      Hi Phil,

      It is possible and something I might look into if I find the time. Essentially I’ll just need to add in an additional column and turn the servers.txt file into a .csv so it can have the description field.

      -Mike

      Like

  7. Madhukar says:

    Hello Mike ,
    i unable to run script proper i unbale to receive report on email
    please help me for the same.

    Thanks,
    MMadhukar

    Like

    1. Mike Galvin says:

      Hi Madhukar,

      I’m happy to help you but can you be more specific as to the problem you are having?

      -Mike

      Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.