Solved

How to import email addresses from a distribution group to CSV

Posted on 2014-10-20
15
138 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
Free eBook: Backup on AWS

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

 
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 Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
EXCH2013 DB 3 9
Decommissioning DNS server question 3 30
office 365 5 14
exchange 2007 9 13
A company’s centralized system that manages user data, security, and distributed resources is often a focus of criminal attention. Active Directory (AD) is no exception. In truth, it’s even more likely to be targeted due to the number of companies …
Active Directory security has been a hot topic of late, and for good reason. With 90% of the world’s organization using this system to manage access to all parts of their IT infrastructure, knowing how to protect against threats and keep vulnerabil…
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…
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 …

762 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