I have multiple domains in our forest and I'm trying to pull a list (csv) of all the members of groups with a PCSupport in the name.
I've been able to get the groups or members of the group in my specific domain but not the others.
One or the other and haven't been able to put it all together. This has gotten me the farthest along, I've got all the groups listed, but I don't know how to feed this into additional scripting to get the groups and members into a csv.
Thanks in advance for any help
$forestName = ([System.DirectoryServices.ActiveDirectory.Forest]::GetCurrentForest()).Name
$ADsPath = [ADSI]"GC://$forestName"
$Search = New-Object System.DirectoryServices.DirectorySearcher($ADsPath)
$Search.Filter = "(&(objectCategory=group)(SamAccountName=*PCSupport))"
$Search.FindAll()
Path
Properties
----
----------
GC://mycompany.com/CN=PCSupport,OU=Groups,DC=domain1,DC=mycompany,DC=com {samaccountname, objectsid, instancetype, objectclass...}
GC://mycompany.com/CN=Co-_PCSupport,OU=Groups-Reserved,OU=ServerWorkstations,D... {info, samaccountname, objectsid, instancetype...}
GC://mycompany.com/CN=PCSupport,OU=Groups,DC=domain2,DC=mycompany,DC=com {samaccountname, objectsid, instancetype, objectclass...}
GC://mycompany.com/CN=PCSupport,OU=Groups,DC=domain3,DC=mycompany,DC=com {samaccountname, objectsid, instancetype, objectclass...}
GC://mycompany.com/CN=PCSupport,OU=Groups,DC=domain4,DC=mycompany,DC=com {samaccountname, objectsid, instancetype, objectclass...}
GC://mycompany.com/CN=PCSupport,OU=Groups,DC=domain5,DC=mycompany,DC=com {samaccountname, objectsid, instancetype, objectclass...}
GC://mycompany.com/CN=PCSupport,OU=Groups,DC=domain6,DC=mycompany,DC=com {samaccountname, objectsid, instancetype, objectclass...}
GC://mycompany.com/CN=PCSupport,OU=Groups,DC=domain7,DC=mycompany,DC=com {samaccountname, objectsid, instancetype, objectclass...}
GC://mycompany.com/CN=PCSupport,OU=Groups,DC=domain8,DC=mycompany,DC=com {samaccountname, objectsid, instancetype, objectclass...}
GC://mycompany.com/CN=PCSupport,OU=Groups,DC=domain9,DC=mycompany,DC=com {samaccountname, objectsid, instancetype, objectclass...}
GC://mycompany.com/CN=PCSupport,OU=Groups,DC=domain10,DC=mycompany,DC=com {samaccountname, objectsid, instancetype, objectclass...}
GC://mycompany.com/CN=PCSupport,OU=Groups,DC=domain11,DC=mycompany,DC=com {proxiedobjectname, samaccountname, objectsid, instancetype...}
Tom