August 1, 2013

Simple WMI Query

Here’s the basic ways to query WMI from Powershell.

Option 1 : With the class and a filter
Get-WmiObject -Class Win32_Directory -filter "Name='c:\\temp'"
Option 2 : With the full query
Get-WmiObject -Query "select * from Win32_Directory where Name='c:\\temp'"
More Info
  • You can also use the GUI tool wbemtest (builtin Windows)
  • You can also use the command line tool wmic (builtin Windows) 
    wmic path Win32_Directory where name='c:\\temp'
  • Backslachs (\) have to be escaped in your query (\\)

No comments:

Post a Comment