Video Screencast Help
Search Video Help Close Back
to help
Not able to make it to Vision this year? Get a sampling in the Best of Vision on Demand group.

Testing WMI

Updated: 25 Jan 2012
Rob Wilcox's picture
0 0 Votes
Login to vote

I looked at an issue the other day where it looked like WMI wasn’t working.  In order to test it, I used the following simple VBScript:

On error resume next

serverDnsName = "exch1.ev.local"

for each objOS in GetObject("winmgmts:\\" + serverDNSName + "\root\cimv2").InstancesOf ("Win32_OperatingSystem")

            wscript.echo "Name = " & objOS.Caption & " Version = " & objOS.Version

next

if err <> 0 then

            wscript.echo err.number

            wscript.echo err.Description

            err.clear

end if

The output will look something like this:

C:\temp>cscript wmi.vbs

Microsoft (R) Windows Script Host Version 5.6

Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.

Name = Microsoft(R) Windows(R) Server 2003, Enterprise Edition Version = 5.2.3790

It might be useful to keep handy, in case you want or need to test it too.