?
Solved

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

Posted on 2010-08-27
7
Medium Priority
?
1,240 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Bringing Advanced Authentication to the SMB Market

WatchGuard announces the acquisition of advanced authentication provider, Datablink, with one mission – to bring secure authentication to SMB, mid-market, and distributed enterprises with a cloud-based solution, ideal for resale via their established channel & MSSP community.

 

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 2000 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

Ransomware Attacks Keeping You Up at Night?

Will your organization be ransomware's next victim?  The good news is that these attacks are predicable and therefore preventable. Learn more about how you can  stop a ransomware attacks before encryption takes place with our Ransomware Prevention Kit!

Question has a verified solution.

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

A procedure for exporting installed hotfix details of remote computers using powershell
The following article is intended as a guide to using PowerShell as a more versatile and reliable form of application detection in SCCM.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

762 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