Categories

Using WQL in PowerShell

WMI Query Language – WQL – is used to either form a query directly or indirectly in the –Filter parameter of Get-WmiObject and Get-CimInstance.

$query = "SELECT * FROM Win32_LogicalDisk WHERE DriveType = 3"
Get-CimInstance -Query $query

OR using the –Filter parameter

Get-CimInstance -ClassName Win32_LogicalDisk -Filter "DriveType = 3"

WQL is a limited subset of SQL.

If you want to find out more there is a help file available in PowerShell 3.0 and above

get-help about_WQL -ShowWindow

One Response to Using WQL in PowerShell

  • Jeffrey Snover [MSFT] says:

    get-help about_WQL -ShowWindow
    Was one of the best things we ever did. I can never remember WQL and could never find the reference pages either. My joke really is true, “PowerShell is such a powerful tool because I am such a weak person” :-)

Leave a Reply

Your email address will not be published. Required fields are marked *

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=""> <strike> <strong>