header image

Using WQL in PowerShell

Posted by: | October 30, 2013 | 1 Comment |

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

under: PowerShell and WMI, PowerShell V3, PowerShell v4

1 Comment

  1. By: Jeffrey Snover [MSFT] on November 2, 2013 at 2:20 pm      

    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” 🙂