WMI scripting can be very useful creating filters to selectively apply Group Policies. It can also be used from the command line to get various bits of information about local or remote hosts.

For example, if you want to find out the version of MS Office installed on your PC, you can use the following:
wmic path Win32_Product WHERE (Caption like "%microsoft office%") get Name, Version

On a remote PC:
wmic /node:remote_pcname path Win32_Product WHERE (Caption like "%microsoft office%") get Name, Version

You can even use it to get information from the BIOS
WMIC BIOS Get Manufacturer,Name,Version

List, start, or stop processes.
wmic process get Name
wmic process call create "calc.exe"
wmic process where name="calc.exe" call terminate

Other useful queries:
Shows MAC Addressess of all network adaptors along with the processes controlling them.
wmic /node:PCNAME path Win32_NetworkAdapter get MACAddress, ProductName, ServiceName

This is only the beginning. Here are a few links for reference.
Windows Management Instrumentation Command
Gathering WMI Data without Writing a Single Line of Code
WMI queries from the command line
WMIC Samples
WMI Classess
Win32_BIOS Class
WMI Tasks for Scripts and Applications
Retrieving System Information
Writing WMI Scripts Using the Scriptomatic Utility

  3 Responses to “WMI Queries”

  1. Service tag number for Dell computers
    wmic /node:dellpc BIOS get SerialNumber

  2. Shutdown a remote computer
    wmic /node:remote_pc path Win32_OperatingSystem get Shutdown(1)

    Flags
    0 (0x0) Log Off
    4 (0x4) Forced Log Off (0 + 4)
    1 (0x1) Shutdown
    5 (0x5) Forced Shutdown (1 + 4)
    2 (0x2) Reboot
    6 (0x6) Forced Reboot (2 + 4)
    8 (0x8) Power Off
    12 (0xC) Forced Power Off (8 + 4)

    Total RAM installed on remote computer
    wmic /node:remote_pc path Win32_ComputerSystem get TotalPhysicalMemory

  3. Supply a list of PCs from a file
    wmic /node:@pclist.txt path Win32_ComputerSystem get Caption, Username
    Will give you usernames of the users logged on the PCs listed in pclist.txt

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

(required)

(required)

   
© 2021 !NSFW Suffusion theme by Sayontan Sinha