Solved

How to export group members (distribution/security) from csv file with groups names

Posted on 2010-08-27
7
1,204 Views
Last Modified: 2012-05-10
Hello,

I'm looking for a script (in Powershell/or Quest cmdlets)  which can import  from csv file with distribution/security groups adres email all members and at the and save it as a nice Excell file with specific columns. This script also should list groups without members.

Example csv input file I attached to this question:  import.csv

Excell file should have these columns: GroupName, Group_email_address, Group_Type(Security/Distribution), Member(samaccountname), Name(First Name+Last Name).

I'll be very thankfull for help
0
Comment
Question by:pi01162
  • 4
  • 3
7 Comments
 
LVL 13

Expert Comment

by:soostibi
ID: 33541499
Could you rewrite the first sentence of your question, as I can not really understand it and attach a more relevant file, as the current one is not very useful...
0
 

Author Comment

by:pi01162
ID: 33556122
Ok, sorry form my bad english ;)

In my domain i have OU=DistributionGroups and OU=SecurityGroups. In these OU's there are exchange distribution groups and security groups.
My task is to report  (in powershell/Quest cmdlets) each group with all members to *.csv file (after that i'll import data to excell).

Finally *.csv file should have these columns: GroupName, Group_email_address, Group_Type(Security/Distribution), Member(samaccountname), Name(First Name+Last Name).

Thanks in advance!
0
 
LVL 13

Expert Comment

by:soostibi
ID: 33556559
What Exchange version do you have?
0
Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

 

Author Comment

by:pi01162
ID: 33556607
Exch2007 Sp2 + Win2008
0
 
LVL 13

Expert Comment

by:soostibi
ID: 33556945
What about this? This script runs in Exchange Server 2007 Management Shell.
You have to update the "yoursubdomain" and "yourdomain" parts. Thsi script gives all the members, not just the mailenabled users, so I put an extra column named "OtherInfo" where you can see if the member is a public folder or non-mail enabled user or contact or etc...
"ou=DistributionGroups,dc=yoursubdomain,dc=yourdomain", "ou=SecurityGroups,dc=yoursubdomain,dc=yourdomain" | 

	%{Get-DistributionGroup -OrganizationalUnit $_} | 

		%{$group = $_ ; Get-DistributionGroupMember $_ | 

			select-object @{n="groupname"; e={$group.name}}, 

				@{n="groupemailaddress";e={$_.primarysmtpaddress}},

				@{n="grouptype";e={if($group.recipientype -match 'SecurityGroup$'){"Security"}else{"Distribution"}}},

				@{n="member(samaccountname)";e={$_.samaccountname}},

				@{n="name(First + Last)"; e={$_.firstname +" " +$_.lastname}},

				@{n="OtherInfo";e={$_.RecipientType}}

			} | Export-Csv c:\groupsandmembers.csv -NoTypeInformation -Encoding UTF8

Open in new window

0
 

Author Comment

by:pi01162
ID: 33557364
Works perfect :)...but can You please modify the script and add "PrimarySmtpAddress" of the group? (not user email).
0
 
LVL 13

Accepted Solution

by:
soostibi earned 500 total points
ID: 33557385
Sorry, see attached modified version.
"ou=DistributionGroups,dc=yoursubdomain,dc=yourdomain", "ou=SecurityGroups,dc=yoursubdomain,dc=yourdomain" |   

        %{Get-DistributionGroup -OrganizationalUnit $_} |   

                %{$group = $_ ; Get-DistributionGroupMember $_ |   

                        select-object @{n="groupname"; e={$group.name}},   

                                @{n="groupemailaddress";e={$group.primarysmtpaddress}},  

                                @{n="grouptype";e={if($group.recipientype -match 'SecurityGroup$'){"Security"}else{"Distribution"}}},  

                                @{n="member(samaccountname)";e={$_.samaccountname}},  

                                @{n="name(First + Last)"; e={$_.firstname +" " +$_.lastname}},  

                                @{n="OtherInfo";e={$_.RecipientType}}  

                        } | Export-Csv c:\groupsandmembers.csv -NoTypeInformation -Encoding UTF8

Open in new window

0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
This script can help you clean up your user profile database by comparing profiles to Active Directory users in a particular OU, and removing the profiles that don't match.
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now