BUG: Query Against Win32_Group Returns Duplicate Instances (321202)



The information in this article applies to:

  • Microsoft Windows Management Instrumentation 1.5

This article was previously published under Q321202

SYMPTOMS

When Windows Management Instrumentation (WMI) populates Win32_Group instances on Microsoft Windows NT 4.0, WMI uses the "BUILTIN" string for the domain property. When you are using WMI to enumerate local groups on a Windows NT 4.0-based computer, you may use a WQL query that is similar to the following query:
   Select * from Win32_Group where Domain="BUILTIN"
				
However, on Microsoft Windows 2000 and later, WMI uses the machine name to populate the same domain property, so the query may be similar to the following WQL query:
   Select * from Win32_Group where Domain ="MyMachineName"
				
A problem occurs with WMI when you try to use the following query that ordinarily returns the appropriate result set on any of the previously mentioned operating systems:
   Select * from Win32_Group where Domain="BUILTIN" OR Domain ="MyMachineName"
				
Because of a bug in WMI, this query returns duplicates of each instance in the result set.

RESOLUTION

To work around this problem, ignore the second set of instances with the same key or keys.

STATUS

Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.

MORE INFORMATION

Steps to Reproduce Behavior

When you run the following script, it returns duplicate values:
dim WMILocator, WMIServices

Set WMILocator = CreateObject("WbemScripting.SWbemLocator")
Set WMIServices = WMILocator.ConnectServer(,"root\cimv2")
Set QueryResultSet = WMIServices.ExecQuery("SELECT * FROM Win32_Group WHERE Domain='BUILTIN' OR Domain='MyMachineName'")

For Each Result in QueryResultSet
  Wscript.Echo Result.Name 
Next 
 
Set QueryResultSet = Nothing
Set WMIServices = Nothing
Set WMILocator = Nothing
				

Modification Type:MinorLast Reviewed:3/20/2004
Keywords:kbDSWManage2003Swept kbbug KB321202