ASSOCIATORS OF
Statement
The
ASSOCIATORS OF
statement retrieves all instances that are associated with a particular source instance. The instances that are retrieved are referred to as the endpoints. Each endpoint is returned as many times as there are associations between it and the source object.
Script de amostra :
option explicit
Dim sResult, strComputer, objWMIService, group, groups, user, users
sResult = ""
strComputer = "."
Set objWMIService = GetObject(_
"winmgmts:{impersonationLevel=impersonate}!\" & strComputer & "\root\cimv2")
Set groups = objWMIService.ExecQuery( "SELECT * FROM Win32_Group" )
For Each group in groups
Set users = objWMIService.ExecQuery( _
"Associators of {Win32_Group.Domain='" & group.Domain _
& "',Name='" & group.Name & "'} " _
& "Where AssocClass = Win32_GroupUser ResultRole = PartComponent")
For Each user in users
sResult = sResult & vbNewLine & group.Domain & " " & group.Name _
& vbTab & user.Name & vbTab & user.SID
Next
Next
Wscript.Echo sResult