Solved

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

Posted on 2010-08-27
7
1,222 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
Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

 

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Utilizing an array to gracefully append to a list of EmailAddresses
This article will help you understand what HashTables are and how to use them in PowerShell.
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…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

726 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