Use WMI and WQL!

Share |

Join PowerShell.com!
Subscribe to Feed

PowerShell eBook
Sign up for
Your PowerTip of the Day:

Award-winning PowerShellPlus


Admin Guide to PowerShell Remoting


Mastering PowerShell eBook

WMI is a great information resource, and Get-WmiObject makes it easy to retrieve WMI instances. First, use -List parameter to find WMI class names. For example, find classes that deal with network:

Get-WmiObject -List Win32_*network*

Next, pick one of the classes and enumerate its instances:

Get-WmiObject Win32_NetworkAdapterConfiguration

With WQL, a SQL-type query language for WMI, you can even create more sophisticated queries, such as:

Get-WmiObject -Query 'Select * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled=True'

To learn more about the specific WQL format and the keywords you can use, check this reference: http://msdn.microsoft.com/en-us/library/windows/desktop/aa394606(v=vs.85).aspx

Twitter This Tip! ReTweet this Tip!


Posted Jan 19 2012, 06:00 AM by ps1
Copyright 2012 PowerShell.com. All rights reserved.