Mr. Roboto

Can You See Me Now?

Sometimes, all you want is a quick reassurance that your server farm is OK. Here's a script to give you some peace of mind.

If you're responsible for maintaining a larger server farm, you've probably invested in some sort of monitoring solution. You want to know at the earliest opportunity if a server goes down or starts misbehaving. Even admins in small to midsize shops might like a tool that offers this peace of mind. This month, Mr. Roboto has a very simple PowerShell script called Display-ComputerStatus.ps1, which you can download from the script library at

In order to run this script, you'll need PowerShell 1.0 installed on your computer -- or wherever you want to run it -- and access to the Windows Management Instrumentation (WMI) service on any remote machine you want to monitor. You'll also need a text list of computer names that you want to monitor, with one computer name per line. If you have scripting experience, you could modify the script to pull names from Active Directory, but I wanted to keep this simple. Download the script and rename it with a .PS1 file extension. Run it from your PowerShell console:

PS C:\Scripts > .\Display-Comput

The first thing you'll notice is the script creates a graphical display. PowerShell doesn't have to be console-based alone. I created this form using PrimalForms, the free forms-builder tool from Sapien, downloadable from the Free Tools section of I've also included the source file if you want to edit it yourself. To use the form, enter the path and file name of your text file and click the Get Status button.

How It Works
First the script pings each computer. If the computer can be pinged, a WMI query is executed against the computer to query the Win32_OperatingSystem class. From this class, the form will display the operating system name, Service Pack and when the computer was last booted. From the last boot time, a total uptime value is calculated and displayed. The script has no provision for alternate credentials, so you need to run it with an account that has administrator rights on all the computers in your list.

Results will be displayed in green text. If the initial ping fails, the results will be displayed in red text. The default display is sorted on the computer name. Clicking column headings won't change the sort, but you can drag and drop to reorder columns. You can also resize the form to stretch out column headings or to hide empty datagrid space.

By default, the script will check all the computers again in five minutes. You can change the interval in five-minute increments up to 60 minutes. One point to remember is that any changes to the interval value won't take effect until the next refresh cycle -- though you can change the value and click Get Status to start a new refresh cycle.

I also added a feature that I hope you'll find useful. Double-click on any computer name in the grid and the computer-management console will launch, connecting to the remote computer. Not only can you see the status of critical servers at a glance, you can also easily manage them.

Scripting in Action
If you open the script file in a scripting editor, such as PrimalScript 2009, you'll notice many Write-Debug commands. These lines display information about what the script is doing, what value a particular variable might have and other useful information. I can turn these lines "on" by setting the $DebugPreference variable to Continue. My script takes a parameter, -debug, that if specified will turn on the debug pipeline and display this debug message:

PS C:\Scripts > .\Display-Comput
erStatus.ps1 -debug

The script has error handling, and will write warning messages for computers to which it can't connect. If you prefer not to see these warnings, use the -NoWarning parameter when running the script:

PS C:\Scripts > .\Display-Comput
erStatus.ps1 -nowarning

This script won't replace a full-featured network-monitoring solution, but it may be just what you need for a quick status and sanity check.

If you have any questions about this script or using PowerShell, please stop by the forums at

About the Author

Jeffery Hicks is an IT veteran with over 25 years of experience, much of it spent as an IT infrastructure consultant specializing in Microsoft server technologies with an emphasis in automation and efficiency. He is a multi-year recipient of the Microsoft MVP Award in Windows PowerShell. He works today as an independent author, trainer and consultant. Jeff has written for numerous online sites and print publications, is a contributing editor at, and a frequent speaker at technology conferences and user groups.


comments powered by Disqus

Subscribe on YouTube