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

Group Members List

$
0
0

I have a script that works, and creates a list of all the groups in my domain and spills them out on screen.

I would like to enhance it so that it changes the distiguished name format to just the CN name of the members.

I would also like to get it to spill the items into a csv file.

I'm not a scripter, i have pieced together scripts in the past and im able to follow powershell enought to eventually get what I want.  But a little help anyone.

Heres the script.

$Groups = Get-ADGroup -Properties * -Filter * -SearchBase "OU=Some OU,OU=Locations,DC=Some Companty,DC=net"

Foreach($G In $Groups)

{

   Write-Host $G.Name

   Write-Host "-------------"

   $G.Members

   Write-Host "                 "

}

Returns

Group Name

------------------

CN=User1,OU=Users,OU=Locations,DC=Some Companty,DC=net

CN=User2,OU=Users,OU=Locations,DC=Some Companty,DC=net

CN=User3 ,OU=Users,OU=Locations,DC=Some Companty,DC=net

What I want is below spilled into a csv file.

Group Name

----------------

User1

User2

User3


Viewing all articles
Browse latest Browse all 15028

Trending Articles



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