StumpedTechy
MIS
Someone on our network made a HUGE mistake and I am trying to fix it. I have tried ADSI and WMI with bad results I don't know if its the query I am using I tried this with ADSI -
strLocalGroup = "Power Users"
strMachineName = "Remote PC"
strDomainGroup = "Domain Group"
strDomainName = "MyDomain"
Dim objLocalGroup, objDomainGroup
on error resume next
'Look up local group.
Set objLocalGroup = GetObject("WinNT://" & strComputerName & "/" & strLocalGroup & ",group")
If err.number <> 0 Then
Log stuff
Err.Clear
End If
' Look up Domain group to be checked against local group.
Set objDomainGroup = GetObject( "WinNT://" & strDomainName & "/" & strDomainGroup & ",group")
If err.number <> 0 Then
Log stuff
Err.Clear
End If
'Check if domain group a member of the local group.
If objLocalGroup.IsMember(objDomainGroup.AdsPath) Then
Log stuff
I even did a
If objLocalGroup.IsMember(objDomainGroup.AdsPath) Then
msg box "yes"
Else
msgbox "no"
but it always says yes. Even on machines I know don't have the domain group in the power users group.
With my WMI the query is so strange I won't go into what I tried because I know it has to be wrong. I was using Win32_UserAccounts.
Any ideas on how I can do this either through WMI or ADSI? I just need to find all PCs on the domain that have this Domain group applied to the Local Power Users group on each individual PC. I alrerady know how to parse a txt file to get the machine names so I just need to know the portion of the query NOT how to make it loop through a bunch of computers.
strLocalGroup = "Power Users"
strMachineName = "Remote PC"
strDomainGroup = "Domain Group"
strDomainName = "MyDomain"
Dim objLocalGroup, objDomainGroup
on error resume next
'Look up local group.
Set objLocalGroup = GetObject("WinNT://" & strComputerName & "/" & strLocalGroup & ",group")
If err.number <> 0 Then
Log stuff
Err.Clear
End If
' Look up Domain group to be checked against local group.
Set objDomainGroup = GetObject( "WinNT://" & strDomainName & "/" & strDomainGroup & ",group")
If err.number <> 0 Then
Log stuff
Err.Clear
End If
'Check if domain group a member of the local group.
If objLocalGroup.IsMember(objDomainGroup.AdsPath) Then
Log stuff
I even did a
If objLocalGroup.IsMember(objDomainGroup.AdsPath) Then
msg box "yes"
Else
msgbox "no"
but it always says yes. Even on machines I know don't have the domain group in the power users group.
With my WMI the query is so strange I won't go into what I tried because I know it has to be wrong. I was using Win32_UserAccounts.
Any ideas on how I can do this either through WMI or ADSI? I just need to find all PCs on the domain that have this Domain group applied to the Local Power Users group on each individual PC. I alrerady know how to parse a txt file to get the machine names so I just need to know the portion of the query NOT how to make it loop through a bunch of computers.