Home > Articles > Operating Systems, Server > Microsoft Servers

Using WSH Scripts with the Windows Management Interface

  • Print
  • + Share This
Network monitors — who needs them? Learn how to use the Windows Management Interface (WMI) to monitor hardware and services.
Like this article? We recommend

Like this article? We recommend

Introduction

The Windows Management Instrumentation (WMI) is a component of the Windows operating system that allows you to interface with the monitoring and management features of Windows for services, applications, or hardware. This article shows how you can use the Windows Scripting Host (WSH) to write scripts that interface with WMI to perform some worthwhile administrative tasks. By accessing the WMI component in your scripts, you can check performance and status for hardware, services, and applications. For example, you could check the status of an email or web server to determine whether the services are up and running—very useful for administrators who need to ensure uptime for mission-critical applications. You could also check to make sure that server hardware is available and performing optimally.

Most Windows operating systems come with a version of WSH. Windows 2000 comes with WSH version 2.0; Windows XP and Windows 2003 Server come with WSH 5.6. The examples in this article use the Visual Basic Scripting edition for WSH 5.6. Each file is saved with the .vbs extension, using a basic text editor. These examples may also work with WSH 2.0, but that's beyond the scope of this article. My examples are for administrators working with the Windows 2003 Server operating system only.

One nice thing about WMI scripting is that you can customize to meet your needs as an administrator, or develop scripts for which network monitors don't have rules. I've explored network monitors, but they can be very expensive for a server license. They also make extensive use of the WMI component to do hardware, service, and application queries to determine status and uptime. By writing your own scripts, you'll not only save a lot of money, but also be able to transfer them to other servers on your network to perform the same tasks that the run-of-the-mill network monitor would. The following section introduces some scripts that monitor hardware aspects of the server; then I'll cover scripts that monitor services and applications.

  • + Share This
  • 🔖 Save To Your Account