Solved

How to import email addresses from a distribution group to CSV

Posted on 2014-10-20
15
140 Views
Last Modified: 2014-10-22
Hi

We use exchange 2007 and outlook 2010.We have two distribution list  Staff and Students in exchange server.
Staff distribution contains 100 users and students distribution group contains 600 users.

I want to import both the staff and students names and mail addresses into a csv.
Is there a  way of importing  these email addresses .Please post me step by step tutorials.

Thanks
0
Comment
Question by:lianne143
[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
  • 8
  • 6
15 Comments
 
LVL 2

Assisted Solution

by:Jeff Lewandowski
Jeff Lewandowski earned 20 total points
ID: 40393241
0
 
LVL 29

Assisted Solution

by:becraig
becraig earned 480 total points
ID: 40393264
Something like this should work for you:
I can tweak further as needed.

	Get-DistributionGroupMember <groupname> | sort Name | % {
		If ($_.RecipientType -eq "UserMailbox")
		{
			$_.Name + " (" + $_.PrimarySMTPAddress + ")" | Out-File c:\file.txt -Append
		}
	}

Open in new window

0
 

Author Comment

by:lianne143
ID: 40393338
Thanks becraig

Do I need to copy and run this command from exchange power shell  replacing <group> with staff to get all the staff name and email address?
0
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 
LVL 29

Assisted Solution

by:becraig
becraig earned 480 total points
ID: 40393354
Yes that would be it, providing the actual name of the DG is "staff"
0
 

Author Comment

by:lianne143
ID: 40393369
I tried entering the command and I am getting the following error.

EnabledPrimarySMTPAddressTemplate "@contoso.com"

[PS] C:\Windows\system32>Get-DistributionGroupMember #Staff Team | sort Nam
e | % {

cmdlet Get-DistributionGroupMember at command pipeline position 1
Supply values for the following parameters:
Identity:               If ($_.RecipientType -eq "UserMailbox")
Get-DistributionGroupMember : The operation could not be performed because
object '        If ($_.RecipientType -eq "UserMailbox")' could not be found on
domain controller 'DC-001.domain.local'.
At line:1 char:1
+ Get-DistributionGroupMember #Staff Team | sort Name | % {
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Get-DistributionGroupMember],
   ManagementObjectNotFoundException
    + FullyQualifiedErrorId : FDF89F70,Microsoft.Exchange.Management.Recipient
   Tasks.GetDistributionGroupMember

[PS] C:\Windows\system32>{
>> $_.Name + " (" + $_.PrimarySMTPAddress + ")" | Out-File c:\Import\members.txt
 -Append
>> }
>> }
>>
0
 

Author Comment

by:lianne143
ID: 40393370
Please let me know if I am missing any thing
0
 
LVL 29

Assisted Solution

by:becraig
becraig earned 480 total points
ID: 40393400
This looks like an issue with the input for the DG call.

Let's verify the DG name
Get-DistributionGroup -Anr staff

Open in new window


Let's verify that you get the actual value for the group you need from that first.
0
 

Author Comment

by:lianne143
ID: 40394728
I ran the following command  and now I get the below.

[PS] C:\Windows\system32>Get-DistributionGroup -Anr StaffTeam

Name                DisplayName         GroupType                     PrimarySmtpAddress
----                -----------         ---------           ------------------
StaffTeam      StaffTeam            Universal, Secur...          StaffTeam@C...


[PS] C:\Windows\system32>
0
 

Author Comment

by:lianne143
ID: 40394819
Hi becraig
Please post me as how I go with next step
Thanks
0
 
LVL 29

Accepted Solution

by:
becraig earned 480 total points
ID: 40394969
So you need to save the below as a  ".ps1" file then run from cmdlet window:

	Get-DistributionGroupMember StaffTeam | sort Name | % {
		If ($_.RecipientType -eq "UserMailbox")
		{
			$_.Name + " (" + $_.PrimarySMTPAddress + ")" | Out-File c:\file.txt -Append
		}
	}

Open in new window

0
 

Author Comment

by:lianne143
ID: 40395824
I saved the script as address.ps1 on C: and ran this from powershell ,please see below.

PS C:\> .\address.ps1
Get-DistributionGroupMember : The term 'Get-DistributionGroupMember' is not recognized as the name of a cmdlet,
function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the
path is correct and try again.
At C:\address.ps1:1 char:1
+ Get-DistributionGroupMember StaffTeam | sort Name | % {
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Get-DistributionGroupMember:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

PS C:\>
0
 
LVL 29

Assisted Solution

by:becraig
becraig earned 480 total points
ID: 40395829
Please run from the exchange cmdlet, as exchange commands are not native to powershell.
0
 

Author Comment

by:lianne143
ID: 40395851
Hi becraig

Thank you soo much for all your post. It worked like a charm.
0
 
LVL 29

Assisted Solution

by:becraig
becraig earned 480 total points
ID: 40395869
Great, we're here to help.
0
 

Author Comment

by:lianne143
ID: 40396715
Many thanks once again and I will give your points.
0

Featured Post

Free eBook: Backup on AWS

Everything you need to know about backup and disaster recovery with AWS, for FREE!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Unable to access folder shares on Netapp 1 19
Certificate Authority Issues 6 48
exchange , email 8 37
Certificate Questions - Exchange 2016 11 37
In-place Upgrading Dirsync to Azure AD Connect
Recently, Microsoft released a best-practice guide for securing Active Directory. It's a whopping 300+ pages long. Those of us tasked with securing our company’s databases and systems would, ideally, have time to devote to learning the ins and outs…
The basic steps you have just learned will be implemented in this video. The basic steps are shown to configure an Exchange DAG in a live working Exchange Server Environment and manage the same (Exchange Server 2010 Software is used in a Windows Ser…
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…

740 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