Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2010-08-27
7
Medium Priority
?
1,249 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
Looking for the Wi-Fi vendor that's right for you?

We know how difficult it can be to evaluate Wi-Fi vendors, so we created this helpful Wi-Fi Buyer's Guide to help you find the Wi-Fi vendor that's right for your business! Download the guide and get started on our checklist today!

 

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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

Windows 10 came with  a lot of built in applications, Some organisations leave them there, some will control them using GPO's. This Article is useful for those who do not want to have any applications in their image (example:me).
Auditing domain password hashes is a commonly overlooked but critical requirement to ensuring secure passwords practices are followed. Methods exist to extract hashes directly for a live domain however this article describes a process to extract u…
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…
Screencast - Getting to Know the Pipeline

610 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