List group membership for all Contacts in an OU
Hi there, I need to output a list of all the groups that each contact (in a specific OU) belongs to.
I can list the contacts in both the Exchange Management Shell, and using the Quest cmdlets, using the following commands:
Get-Contact -ResultSizeUnlimited -OrganizationalUnit "Domain/OrganizationalUnit"
get-QADObject -SizeLimit 0 -Type 'contact' -OrganizationalUnit "Domain/OrganizationalUnit"
How do I then output each contact's group membership?
Thanks in advance.
April 19th, 2012 2:53am
put those contacts in a csv file.
contacts
externaluser1@compan1.com
externuser2@company2.com
import-csv testfile.txt |foreach {get-qadobject $_.contacts} |select name, memberofJames Chong MCITP | EA | EMA; MCSE | M+, S+ Security+, Project+, ITIL msexchangetips.blogspot.com
Free Windows Admin Tool Kit Click here and download it now
April 19th, 2012 1:38pm
Thanks so much James, this is perfect!
For anybody else, I've been able to combine this into two lines that perform what I need - using the Quest cmdlets:
get-QADObject -SizeLimit 0 -Type 'contact' -OrganizationalUnit "YourDomain/OrganizationalUnitName" | Export-CSV Contacts.txt
import-csv Contacts.txt |foreach {get-QADobject $_.PrimarySMTPAddress} | ft name, memberof -wrap >contactgroupmembership.txt
Obviously would need to change "YourDomain/OrganizationalUnitName" to your domain name & OU.
Thanks again James!
April 19th, 2012 10:23pm