Help with Get-ADGroup: How can I list all members without the full CN/OU path for each as a comma seperated list within a single cell in the output CSV?

Get-ADGroup -Filter ‘GroupCategory -eq 0′ -Properties * | Select Name, DisplayName, Description, Mail, @{n=’Group Members’;e={$.Members -replace “CN=$($.cn),”,”}} | export-csv c:export.csv

The export gives me output like: Name: “Group A” DisplayName: “Group A” Description: “This is a test group” Mail: “” Members: {CN=User1,OU=Users,DC=contoso,DC=com, CN=user2,OU=someOtherOU,OU=Users,OU=contoso,DC=com…}

How can I have the output for “Members” look like:

Members: “User1, User2, …”

submitted by /u/tehrabbitt
[link] [comments]

Leave a Reply