Quantcast
Channel: /r/powershell – How to Code .NET
Viewing all articles
Browse latest Browse all 8793

Help formatting output of select-object

$
0
0

Not sure if I worded the title properly or not, but I’m trying to search ADGroups in a specific OU and return members and memberof then export to csv.

$DateTime = get-date -f "yyyyMMdd-HHmmss" $path = "C:users$env:usernamedesktopGet-ADGroupProperties_$DateTime.csv" get-ADGroup -filter * -searchbase "OU=someOU, OU=someOU, DC=someDC, DC=someDC, DC=someDC" -properties description,whencreated,whenchanged,members,memberof | select-object -Property Name,GroupCategory,GroupScope, @{N="Members";E={$_.members}},@{N="MemberOf";E={$_.MemberOf}},whenchanged,whencreated | sort-object -Property Name | export-csv -path "$path" ii $path 

For members and memberOf, the results are CN=UserID,OU=someOU,DC=someDC.

Is there a way I can return only the CN so it just displays the UserIDs and nothing else?

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

The post Help formatting output of select-object appeared first on How to Code .NET.


Viewing all articles
Browse latest Browse all 8793

Trending Articles