Windows Server Status Monitor v1.7

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.

I take great care to test my ideas and make sure my articles are accurate before posting, however mistakes do slip through sometimes. If you’d like to get in touch with me please use the comments, Twitter (you can tweet me and my DMs are open) or my contact form.

I hope this article helps you out, please consider supporting my work here. Thank you.

-Mike

 

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
-Subject No The subject line that the email should have. Encapsulate with single or double quotes. ‘Server: Notification’
-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-09-04 v1.7

  • Added custom subject line for e-mail.

2019-02-23 v1.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)./li>

2018-06-10 v1.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 v1.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 v1.3

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

2017-10-09 v1.2

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

2018-09-27 v1.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 v1.0

  • First public release.

 

24 thoughts on “Windows Server Status Monitor v1.7

Add yours

    1. 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

    1. 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

    1. 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

  1. 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. 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

  2. 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. 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

  3. 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.

    Liked by 1 person

    1. 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

      Liked by 1 person

  4. Hi,
    The Script and its Output is very nice. However, in the Disk space area, if the machine has multiple drives like Drive C; Drive E: and Drive F. The Percentage symbol is not visible on the first 2 drives and only visible in the last drive.

    Thanks.

    Like

  5. Hi Mike,

    Is there any chance to add optional check to the script?
    For instance if one also needs to monitor AV status on endpoints where there’s not centralized management, they can set script to also send AV alerts for disabled or out of date AV and also show new field on the html when this is enabled?

    Learning powershell so figured I’d try my hand at creating my own AV check script, haven’t gotten far yet but here’s what I have at the moment.
    ===================

    $computer = $env:COMPUTERNAME
    $namespace = “ROOT\SecurityCenter2”
    $fwclass = “FirewallProduct”
    $avclass = “AntivirusProduct”
    $asclass = “AntiSpywareProduct”
    $avfilter = “notlike ‘Windows Defender’ ” (not used, need to be able to set the antivirus product being used by company and ignore others)

    $AV = Get-CimInstance -ComputerName $computer -Namespace $namespace -ClassName $avclass | Select PSComputerName, DisplayName, ProductState
    $AS = Get-CimInstance -ComputerName $computer -Namespace $namespace -ClassName $asclass | Select PSComputerName, DisplayName, ProductState
    $FW = Get-CimInstance -ComputerName $computer -Namespace $namespace -ClassName $fwclass | Select PSComputerName, DisplayName, ProductState

    $AS
    $AV
    $FW
    =================
    [Result]
    PSComputerName DisplayName ProductState
    ————– ———– ————
    XXXXXXXXX Trend Micro Apex One Anti-spyware 266240
    XXXXXXXXX Windows Defender 393472
    XXXXXXXXX Windows Defender 393472
    XXXXXXXXX Trend Micro Apex One Antivirus 266240
    XXXXXXXXX Trend Micro Personal Firewall 266240
    =========================
    Still need to replace the productstate to show the values in bracket for in place of the corresponding numbers.
    “262144” {“Disabled, Up to date”}
    “262160” {“Disabled, Out of date”}
    “266240” {“Enabled, Up to date”}
    “266256” {“Enabled, Out of date”}
    “393216” {“Disabled, Up to date”}
    “393232” {“Disabled, Out of date”}
    “393488” {“Disabled, Out of date”}
    “397312” {“Enabled, Up to date”}
    “397328” {“Enabled, Out of date”}
    “397584” {“Enabled, Out of date”}
    “397568” {“Enabled, Up to date”}
    “393472” {“Disabled, Up to date”}
    ===================

    Is it worth working this into the monitoring script or stick to running separate script for AV status?
    I know there’s a bunch of AV monitoring scripts out there already

    Thanks.

    Like

    1. Hi there,

      I like your idea but for now I want to try and improve the performance before adding any extra features. In all honestly I did create it just as a very basic “are the servers up and do they have disk space?” monitor. I have put the code for this and all my scripts on GitHub so people can fork them and create their own if they want to.

      Thanks,
      Mike

      Like

      1. Thanks.
        I agree with you, better to have a couple of great scripts that work really well for specific uses than a single script that does several things with some issues.

        Not at the point of modifying advanced scripts such as yours yet, but I’ll update if I figure out something decent enough to share!.

        Thanks

        Like

Leave a Reply to Jasper Cancel 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.

Create a website or blog at WordPress.com

Up ↑

%d bloggers like this: