beautypg.com

HP Insight Management WBEM Providers User Manual

Page 25

background image

The following are example codes for accessing Insight Provider data using VBScript code.

This VBScript code is used to display computer system operational status information:

strComputer = "."

strNamespace = "\root\hpq"

Set objWMIService = GetObject("winmgmts:\\" & strComputer & strNamespace)

Set colComputerSystem = objWMIService.ExecQuery("Select * from HP_WinComputerSystem")

For Each objComputerSystem in colComputerSystem

WScript.Echo "Caption: " & objComputerSystem.Caption

For Each objStatusDescription in objComputerSystem.StatusDescriptions

WScript.Echo "Status description: " & objStatusDescription

Next

For Each objOperationalStatus in objComputerSystem.OperationalStatus

WScript.Echo "Operational status: " & objOperationalStatus

Next

Next

The following VBScript code is used to display system firmware version:

strComputer = "."

strNamespace = "\root\hpq"

Set objWMIService = GetObject("winmgmts:\\" & strComputer & strNamespace)

Set colSystemROMFirmware = objWMIService.ExecQuery("Select * from HP_SystemROMFirmware")

For Each objSystemROMFirmware in colSystemROMFirmware

WScript.Echo "Caption: " & objSystemROMFirmware.Caption

WScript.Echo "Version: " & objSystemROMFirmware.VersionString

WScript.Echo

Next

This VBScript code is used to display computer system chassis model name, serial number and
asset tag:

strComputer = "."

strNamespace = "\root\hpq"

Set objWMIService = GetObject("winmgmts:\\" & strComputer & strNamespace)

Set colComputerSystemChassis = objWMIService.ExecQuery("Select * from HP_ComputerSystemChassis")

For Each objComputerSystemChassis in colComputerSystemChassis

WScript.Echo "Model: " & objComputerSystemChassis.Model

WScript.Echo "Serial number: " & objComputerSystemChassis.SerialNumber

WScript.Echo "Asset tag: " & objComputerSystemChassis.UserTracking

Next

This VBScript code is used to list system memory modules and their capacities:

strComputer = "."

strNamespace = "\root\hpq"

Set objWMIService = GetObject("winmgmts:\\" & strComputer & strNamespace)

Set colMemoryModule = objWMIService.ExecQuery("Select * from HP_MemoryModule")

For Each objMemoryModule in colMemoryModule

WScript.Echo "Caption: " & objMemoryModule.Caption

WScript.Echo "Capacity (bytes): " & objMemoryModule.Capacity

Wscript.Echo

Next

This VBScript code is used to list system processors, current clock speed, and the number of enabled
cores:

Microsoft Visual Basic Scripting Edition examples

25