HP DL360 HP Insight Management WBEM Providers for Windows Server 2003 and Wind - Page 33

Scripting, Scripting examples, WMIC example, Scripting references

Page 33 highlights

Scripting Scripting examples This section provides examples for accessing data exposed by the Insight Providers using scripting. WMIC example You can also write scripts to obtain data from the Insight Providers using WMIC and Microsoft® Windows® PowerShell. The following command is used to display computer system status information using WMIC in noninteractive mode: wmic /namespace:\\root\hpq path hp_wincomputersystem get caption,OperationalStatus,StatusDescriptions The following Windows PowerShell script code can be used to list fans in the system: $strComputer = "." $strNamespace = "root\hpq" $colFan = Get-WMIObject -class "hp_winfan" -namespace $strNamespace computername $strComputer foreach ($objFan in $colFan) { write-host $objFan.Name, $objFan.Description } Scripting references For more information regarding WMI scripting, see the following WMI references on the MSDN website (http://msdn.microsoft.com): • Scripting Access to WMI (http://msdn2.microsoft.com/en-us/library/aa393256.aspx) • Visual Basic Scripting Edition (http://msdn2.microsoft.com/en-us/library/t0aew7h6.aspx) • WMIC (http://msdn2.microsoft.com/en-us/library/aa394531.aspx) • Windows® PowerShell (http://msdn2.microsoft.com/en-us/library/bb905330.aspx) Scripting 33

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41

Scripting 33
Scripting
Scripting examples
This section provides examples for accessing data exposed by the Insight Providers using scripting.
WMIC example
You can also write scripts to obtain data from the Insight Providers using WMIC and Microsoft®
Windows® PowerShell.
The following command is used to display computer system status information using WMIC in
noninteractive mode:
wmic /namespace:\\root\hpq path hp_wincomputersystem get
caption,OperationalStatus,StatusDescriptions
The following Windows PowerShell script code can be used to list fans in
the system:
$strComputer = "."
$strNamespace = "root\hpq"
$colFan = Get-WMIObject -class "hp_winfan" -namespace $strNamespace -
computername $strComputer
foreach ($objFan in $colFan) {
write-host $objFan.Name, $objFan.Description
}
Scripting references
For more information regarding WMI scripting, see the following WMI references on the MSDN website
(
):
Scripting Access to WMI (
)
Visual Basic Scripting Edition (
)
WMIC (
)
Windows® PowerShell (
)