PowerShell for Windows Admins

Aug 28 2010   5:07AM GMT

WQL wildcards

Richard Siddaway Richard Siddaway Profile: Richard Siddaway

 

Get-WmiObject -Class Win32_NetworkAdapter 

will show us a list of network adapters.  We can narrow this down to a specific adapter

Get-WmiObject -Class Win32_NetworkAdapter -Filter "DeviceId=’11′" | fl *

What if we know that there is a NIC that is labelled as Wireless something or other.  We have two options

Get-WmiObject -Class Win32_NetworkAdapter | where {$_.NetConnectionID -like "wireless*"}

use the where-object cmdlet and filter using a like statement or

Get-WmiObject -Class Win32_NetworkAdapter -Filter "NetConnectionID LIKE ‘wireless%’"

filter in the get-wmiobject. Note that the wildcard symbol is % NOT * in the filter parameter. This is because we are using WQL which is a subset of SQL.

We could also write this as

Get-WmiObject -Query "SELECT * FROM Win32_NetworkAdapter WHERE NetConnectionID LIKE ‘wireless%’"

The WQL equivalent of the single character wildcard “?” is _ so we could write

Get-WmiObject -Query "SELECT * FROM Win32_NetworkAdapter WHERE NetConnectionID LIKE ‘_ireless%’"

More information on WQL wildcards can be found

http://msdn.microsoft.com/en-us/library/aa392263(v=VS.85).aspx

 Comment on this Post

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when other members comment.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to: