Solved

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

Posted on 2010-08-27
7
1,195 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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Synchronize a new Active Directory domain with an existing Office 365 tenant
This article will help you understand what HashTables are and how to use them in PowerShell.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

758 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

18 Experts available now in Live!

Get 1:1 Help Now