[gptalk] Re: WMI Question

  • From: "Darren Mar-Elia" <darren@xxxxxxxxxx>
  • To: <gptalk@xxxxxxxxxxxxx>
  • Date: Wed, 18 Jul 2007 10:38:33 -0700

Jason-

Most of the things you are interested in are going to be in the root\CIMv2
namespace. Also, note that Windows (as of I think, XP) comes with a little
tool called wbemtest.exe that lets you connect to the WMI namespace and do
some queries and enumerations of classes and properties. Its not terribly
intuitive however. My tool of choice for browsing WMI is called WMIX
(http://wmix.pjtec.com/) . Its pretty cool. 

 

Darren

 

From: gptalk-bounce@xxxxxxxxxxxxx [mailto:gptalk-bounce@xxxxxxxxxxxxx] On
Behalf Of Jason Williams
Sent: Wednesday, July 18, 2007 10:29 AM
To: gptalk@xxxxxxxxxxxxx
Subject: [gptalk] Re: WMI Question

 

Wow....lots of power here...lots to learn as well. :)

 

Just playing around when creating a WMI, what should the NAMESPACE be? Right
now, I show: root\CIMv2

 

Very cool stuff. I like...just need to start learning this. :)

 

Cheers,


Jason

 

On 7/18/07, Nelson, Jamie R Contr 72 CS/SCBAF
<Jamie.Nelson.ctr@xxxxxxxxxxxxx> wrote: 

You can also use LIKE statements in your WMI filter. The following would
work for what you are trying to do.

 

SELECT * FROM Win32_OperatingSystem WHERE Caption LIKE '%Windows XP%'

 

For more information on WMI filters, you can check out the following
Microsoft HOWTO. It breaks down the process and has some related links you
can visit to learn more about WMI. 

 

HOWTO: Leverage <http://support.microsoft.com/kb/555253>  Group Policies
with WMI Filters 

 

Regards,

 

Jamie Nelson

 

From: gptalk-bounce@xxxxxxxxxxxxx [mailto:gptalk-bounce@xxxxxxxxxxxxx] On
Behalf Of Kees Baggerman
Sent: Wednesday, July 18, 2007 10:48 AM 
To: gptalk@xxxxxxxxxxxxx
Subject: [gptalk] Re: WMI Question

 

JW,

 

You could use the following VBS Script to get the name of the OS

 

strComputer = "."
Set WshShell = WScript.CreateObject("WScript.Shell")
Dim WshShell
Set objWMIService = GetObject("winmgmts:" &
"{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") 
Set colOperatingSystems = objWMIService.ExecQuery ("Select * from
Win32_OperatingSystem")
For Each objOperatingSystem in colOperatingSystems
wscript.echo objOperatingSystem.Caption
Next 

 

If you take the output of the script you can create a WMI Filter in the
GPMC:

 

Namespace: 
root\CIMv2

Query:
Select * from Win32_OperatingSystem where Caption = "Microsoft(R) Windows(R)
Server 2003, Enterprise Edition" 

 

Where Microsoft(R) Windows(R) Server 2003, Enterprise Edition the OS name
is.

 

With this example you only process the GPO if the OS is Windows 2003
Enterprise.

 

 

Kind regards,

 

Kees Baggerman

 

From: gptalk-bounce@xxxxxxxxxxxxx [mailto:gptalk-bounce@xxxxxxxxxxxxx] On
Behalf Of Jason Williams
Sent: Wednesday, July 18, 2007 5:43 PM 
To: gptalk@xxxxxxxxxxxxx
Subject: [gptalk] WMI Question

 

I am jumping into some situations where I am going to need to get started
with WMI scripting. For example, we have a GPO that sets XP Firewall
policies and it looks like it is causing problems with our Vista machines
and their firewalls. 

 

I thought this would be a good time to get started with WMI and make this
policy only apply to XP machines. However, I am not sure where to begin.

Not sure if this is the place or not, but was wondering if someone can point
me to some links on how to get started with scripting for WMI?

 

Appreciate it.


JW

 

Other related posts: