C
Chris Sharp
I seem to be stuck on the proper binding method or deletion method to the
members of the local groups who are domain groups/users.
The other problem is in determining if it's a group or user when deleting
the object. Much appreciated for any help! -CPSharp
Set objNetwork = CreateObject("WScript.Network")
strComputer = objNetwork.ComputerName
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems2 = objWMIService.ExecQuery("Select Name from Win32_Group" _
& " Where LocalAccount=True")
For Each objGroup In colItems2
Set filtGroups = GetObject("WinNT://" & strComputer & "/" & objGroup.Name
& ",group")
Set filtObjects = GetObject("WinNT://" & strComputer & "/" &
filtGroups.Members) 'not sure if this is working
For each objLocalGrp in filtGroups.Members
If InStr(1, objLocalGrp.ADsPath, strComputer, vbTextCompare) = 0 AND _
InStr(1, objLocalGrp.ADsPath, "MYDOMAIN", vbTextCompare) <> 0 Then
objLocalGrp.Delete "user", objLocalGrp.Name
objLocalGrp.Delete "group", objLocalGrp.Name
End If
Next
Next
members of the local groups who are domain groups/users.
The other problem is in determining if it's a group or user when deleting
the object. Much appreciated for any help! -CPSharp
Set objNetwork = CreateObject("WScript.Network")
strComputer = objNetwork.ComputerName
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems2 = objWMIService.ExecQuery("Select Name from Win32_Group" _
& " Where LocalAccount=True")
For Each objGroup In colItems2
Set filtGroups = GetObject("WinNT://" & strComputer & "/" & objGroup.Name
& ",group")
Set filtObjects = GetObject("WinNT://" & strComputer & "/" &
filtGroups.Members) 'not sure if this is working
For each objLocalGrp in filtGroups.Members
If InStr(1, objLocalGrp.ADsPath, strComputer, vbTextCompare) = 0 AND _
InStr(1, objLocalGrp.ADsPath, "MYDOMAIN", vbTextCompare) <> 0 Then
objLocalGrp.Delete "user", objLocalGrp.Name
objLocalGrp.Delete "group", objLocalGrp.Name
End If
Next
Next