Solved

How to import email addresses from a distribution group to CSV

Posted on 2014-10-20
15
132 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
  • 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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
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

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

Lotus Notes – formerly IBM Notes – is an email client application, while IBM Domino (earlier Lotus Domino) is an email server. The client possesses a set of features that are even more advanced as compared to that of Outlook. Likewise, IBM Domino is…
Scam emails are a huge burden for many businesses. Spotting one is not always easy. Follow our tips to identify if an email you receive is a scam.
To show how to generate a certificate request in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.:  First we need to log into the Exchange Admin Center. Navigate to the Servers >> Certificates…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

808 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