Hi,
I am trying to use the below code to return an echo based on the machines AD group. When i run it nothing at all happens. The machine is in the group listed in the file. Can anyone help please?
Thanks
Code:on error resume next lgCnt=oP.Count Do While lgCnt>0 lgCnt=lgCnt-2 Loop Set WShell = CreateObject("WScript.Shell") If IsComputerMember("C204") Then Wscript.Echo "204" If IsComputerMember("C205") Then Wscript.Echo "205" 'End If ' ***************** ' *** End *** ' ***************** Function IsMember(strGroup) ' Function to test for group membership, ' returns True If the user or computer is a member of the group. If IsEmpty(objGroupList) Then Call LoadGroups End If IsMember = objGroupList.Exists(strGroup) End Function Function IsComputerMember(sGroup) Dim oGroup on error resume next Set oGroup = GetObject("WinNT://" & strDomain & "/" & sGroup & ",group") IsComputerMember = CBool(oGroup.IsMember(objComputer2.ADsPath & "$")) Set oGroup = Nothing If not Err.Number = 0 Then 'isComputerMember could not locate group end if on error goto 0 End Function Sub LoadGroups() '------------------------------------------------ ' Subroutine to populate dictionary object with group memberships. ' objUser is the user or computer object, with global scope. ' objGroupList is a dictionary object, with global scope. Dim arrbytGroups, j, arrstrGroupSids(), objGroup Set objGroupList = CreateObject("Scripting.Dictionary") objGroupList.CompareMode = vbTextCompare objUser.GetInfoEx Array("tokenGroups"), 0 arrbytGroups = objUser.Get("tokenGroups") If TypeName(arrbytGroups) = "Byte()" Then ReDim arrstrGroupSids(0) arrstrGroupSids(0) = OctetToHexStr(arrbytGroups) Set objGroup = GetObject("LDAP://<SID=" & arrstrGroupSids(0) _ & ">") objGroupList(objGroup.sAMAccountName) = True Set objGroup = Nothing Exit Sub End If If UBound(arrbytGroups) = -1 Then Exit Sub End If ReDim arrstrGroupSids(UBound(arrbytGroups)) For j = 0 To UBound(arrbytGroups) arrstrGroupSids(j) = OctetToHexStr(arrbytGroups(j)) Set objGroup = GetObject("LDAP://<SID=" & arrstrGroupSids(j) _ & ">") objGroupList(objGroup.sAMAccountName) = True Next Set objGroup = Nothing End Sub '------------------------------------------------------------


LinkBack URL
About LinkBacks

you don't need the 2nd instance of that either. 

