AzleISD
asked on
Vbscript to enum groups and group memebrs from a specific OU not from Root of AD
I have run the script from solution:
https://www.experts-exchange.com/questions/24978862/vbscript-to-dump-all-distribution-lists-plus-their-members-to-a-csv-file.html
It works great for just Distribution groups. The problem I have is that some of the groups we use for distributiol groups are Security groups. I have organized them in a ou in ad the Dn is:
OU=Groups - Distribution,DC=azle,DC=es c11,DC=net
I need to run this script to look at both dist groups and security groups.. Please Help!! thanks..
https://www.experts-exchange.com/questions/24978862/vbscript-to-dump-all-distribution-lists-plus-their-members-to-a-csv-file.html
It works great for just Distribution groups. The problem I have is that some of the groups we use for distributiol groups are Security groups. I have organized them in a ou in ad the Dn is:
OU=Groups - Distribution,DC=azle,DC=es
I need to run this script to look at both dist groups and security groups.. Please Help!! thanks..
Set oRootDSE = GetObject("LDAP://RootDSE")
Set objConn = CreateObject("ADODB.Connection")
Set objComm = CreateObject("ADODB.Command")
objConn.Provider = "ADsDSOObject"
objConn.Open "Active Directory Provider"
Set objComm.ActiveConnection = objConn
objComm.Properties("Page Size") = 1000
strBase = "<LDAP://" & oRootDSE.get("defaultNamingContext") & ">;"
strFilter = "(sAMAccountType=268435457);"
strAttrs = "distinguishedName,memberof,sAMAccountName;"
strScope = "subtree"
objComm.CommandText = strBase & strFilter & strAttrs & strScope
Set objRS = objComm.Execute
objRS.MoveFirst
Do Until objRS.EOF
Set objGroup = GetObject("LDAP://" & Replace(objRS.Fields("distinguishedName").Value,"/","\/"))
WScript.Echo objGroup.cn & "," & memberString(objGroup)
objRS.MoveNext
Loop
Set oRootDSE = Nothing
Set objConn = Nothing
Set objComm = Nothing
Set objUser = Nothing
Function memberString(objGroup)
If Not IsEmpty(objgroup.member) Then
For Each memberDN In objGroup.GetEx("member")
Set objMember = GetObject("LDAP://" & memberDN)
out = out & objmember.cn & "; "
Next
End If
If Right(out,2) = "; " Then out = Left(out,Len(out)-2)
memberString = out
End Function
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
oh sorry, give me a few minutes.
ASKER
not a problem Thanks for the quick response!!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
That is is thanks for your help!
ASKER