Solved

How to import email addresses from a distribution group to CSV

Posted on 2014-10-20
15
128 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
 
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
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.

 

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

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

Following basic email etiquette rules will help you write a professional email and achieve a good, lasting impression with your contacts.
Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
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…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …

867 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

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now