Querying WMI

Querying WMI

Here are some examples of how to query WMI via cmdline/scripting.

Table of Contents




WMIC

Retrieve all properties related to the Operating System class

    wmic OS

Retrieve the Version property of the Operaring System class

    wmic OS get Version

Retrieve the Version property of the Operaring System class on the specified computer

    wmic OS /node:<computername> get Version

VBScript

Retrieve all properties of the Operating System class on the local computer.  The strComputer variable can be changed to the name of a remote computer.

strComputer = "." 
strNameSpace = "root\cimv2" 
strClass = "Win32_OperatingSystem" 
  
Set objClass = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _  
    strComputer & "\" & strNameSpace & ":" & strClass) 
  
WScript.Echo strClass & " Class Properties" 
WScript.Echo "------------------------------" 
  
For Each objClassProperty In objClass.Properties_ 
    WScript.Echo objClassProperty.Name 
Next 

PowerShell



Retrieve all properties related to the Operating System class

    Get-WmiObject Win32_OperatingSystem

Retrieve the Version property of the Operaring System class

    Get-WmiObject Win32_OperatingSystem | Select Version

Retrieve the Version property of the Operaring System class on the specified computer

    Get-WmiObject Win32_OperatingSystem -Computername <ComputerName> | Select Version
Leave a Comment
  • Please add 3 and 3 and type the answer here:
  • Post
Wiki - Revision Comment List(Revision Comment)
Sort by: Published Date | Most Recent | Most Useful
Comments
  • Richard Mueller edited Revision 3. Comment: Removed (en-US) from title, added tags

  • Craig Lussier edited Revision 2. Comment: added en-US to tags and title

  • Rich Prescott edited Original. Comment: Indented code for readability

Page 1 of 1 (3 items)
Wikis - Comment List
Sort by: Published Date | Most Recent | Most Useful
Posting comments is temporarily disabled until 10:00am PST on Saturday, December 14th. Thank you for your patience.
Comments
  • Rich Prescott edited Original. Comment: Indented code for readability

  • Craig Lussier edited Revision 2. Comment: added en-US to tags and title

  • Richard Mueller edited Revision 3. Comment: Removed (en-US) from title, added tags

Page 1 of 1 (3 items)