Revision #1

You are currently reviewing an older revision of this page.
Go to current version
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
Revert to this revision