Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Script To Pull MemberOf & List The Group Type

$
0
0

So this is my first script, i need it to get a list of all the groups that the target is a member of and what the group type is.

What actually happens is the group type for the target gets repeated after every line instead of the MemberOf group

It would be nice to get the group name without the full LDAP name as well if possible, but that is not necessary

----------

On Error Resume Next

Dim fso
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.CreateTextFile("C:\Users\%USERNAME%\Desktop\output.csv", True)

Set objGroup = GetObject _
  ("LDAP://LDAP NAME")
objGroup.GetInfo

arrMembersOf = objGroup.GetEx("memberOf")

objfile.writeline "MembersOf"
For Each strMemberOf in arrMembersOf
objfile.write strMemberOf
Select Case objGroup.GroupType
    Case 2
        objfile.writeline ",Global Distribution"
    Case 4
        objfile.writeline ",Domain Local Distribution"
    Case 8
        objfile.writeline ",Universal Distribution"
    Case -2147483646
        objfile.writeline ",Global Security"
    Case -2147483644
        objfile.writeline ",Domain Local Security"
    Case -2147483640
        objfile.writeline ",Universal Security"
End Select
next

f.Close

-----------
Can anyone help

Thanks in advance

Brian


Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>