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

Published Wed, Oct 30 2013 22:05 by RichardSiddaway

Comments

# re: Using WQL in PowerShell

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"  :-)

Saturday, November 02, 2013 2:20 PM by Jeffrey Snover [MSFT]

Leave a Comment

(required) 
(required) 
(optional)
(required) 
If you can't read this number refresh your screen
Enter the numbers above: