Get all users in an ADgroup with the displayname

I am trying to get the members of a list of groups from a csv. The script i created below outs puts the group names. My question is : I want to get AD user’s “Display name” instead of users name.

get-content "C:tempglist.csv" | foreach {get-adgroup -identity "$_" -properties * | select Name,Description, @{n='Members';e={$_.members -replace '^cn=([^,]+).+$','$1' -join '; '}} | export-csv "C:tempgroup_info $currentdate.csv" -NoTypeInformation -Encoding UTF8} 

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

Leave a Reply