WMI Filtering, Targeting, Usage & Utilities

WMI filtering is a very neat tool. I personally find its syntax a little complicated. Recently I came across with this 2 line article. How to WMI Filter with computer name. Here is an example.

select * from Win32_ComputerSystem where Name = ‘Computer Name’

If you are looking for more WMI Filter examples, this article has it all…

http://blog.enx1.com/2011/07/03/wmi-gpo-filters-for-operating-system-types/

Here is another example of how to target Windows 7 by its architecture type (X86 or X64). This is great while deploying applications through Group Policy. Not all the applications are compatible both 32 and 64 bit, so you can target only 32bit or only 64bit computers with the help of this WMI query.

Here is how it looks like to target only Windows 7 X86 Systems



select * from Win32_OperatingSystem WHERE Version like "6.1%" AND ProductType="1" AND NOT OSArchitecture = "64-bit"


Targeting Windows 7 X64 Systems



select * from Win32_OperatingSystem WHERE Version like "6.1%" AND ProductType="1" AND OSArchitecture = "64-bit"


But, how do you make sure that these WMI queries are actually working? Of course, you can go ahead and try to apply it to a GPO and try on with a couple of machines… Or you can download this little utility from the www.gpoguy.com website written by Darren Mar-Elia. This tool is handy when it comes to try out your WMI filters in your GPO. The tool can pull all configured queries from your Active Directory and validate them. If you are working a lot with GPO’s and WMI’s, this tool is a must have. Here is the link to the download page;
http://www.gpoguy.com/FreeTools/FreeToolsLibrary/tabid/67/agentType/View/PropertyID/93/Default.aspx

I thought, while we are in the subject, why don’t I give away all my secret weapons in terms of WMI coding…
Here is a little list of tools that might save you hours of work and make you look like a decent programmer J

PowerGUI A Graphical User Interface and script editor for Microsoft Windows PowerShell
 
WMICode Creator Generates code in VBScript, C#, and Visual Basic® .NET; you can run the code directly from the tool. You can generate code to query for management information, execute a management task, or receive event notifications.
 
Scriptomatic 2.0
This utility that writes WMI scripts for you. (And, in the process, teaches you the fundamental concepts behind writing WMI scripts for yourself.)

Comments

Popular posts from this blog

System.Messaging.MessageQueueException (0x80004005): A workgroup installation computer does not support the operation (Public Queue create issue)

Veeam Backup Error : Failed to prepare guest for hot backup. Error: VSSControl

warning: Win32API is deprecated after Ruby 1.9.1; use fiddle directly instead - Chef Development Kit Update