Author Posts

January 1, 2012 at 12:00 am

by GeorginaHowland at 2012-11-22 08:55:24

New to powershell
I would like to query active directory to get memberof however should only display CN=
what I am currently typing

Get-Aduser USERNAME -property memberof

MemberOf : {CN=ITIM_PW_Team_Members,OU=Groups,OU=IT Services,DC=internal,DC=Heritage,DC=ca, CN=HO_IT_Serv
roups,OU=Head Office,DC=internal,DC=Heritage,DC=ca, CN=CBS_Equipment_Disposal_R,OU=Groups,OU=H
e,DC=internal,DC=Heritage,DC=ca, CN=TWGAdmins,OU=Groups,OU=Head Office,DC=internal,DC=Heritage

would like to display

memberof
CN=ITIM_PW_Team_Members
CN=HO_IT_Services
CN=CBS_Equipment_Disposal_R

by DonJ at 2012-11-23 12:18:22

You're going to have to enumerate the MemberOf collection. If it's just strings, which I suspect it is, you'll have to parse those strings out yourself. Kind of a pain, actually.

by GeorginaHowland at 2012-11-27 08:17:03

Thank you

by mikefrobbins at 2012-11-27 09:18:52

(Get-Aduser USERNAME -property memberof).memberof -replace "\,.*"
or

(Get-Aduser USERNAME -property memberof | select -expand memberof) -replace "\,.*"