Solved

How to import email addresses from a distribution group to CSV

Posted on 2014-10-20
15
120 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 28

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 28

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 28

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
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 

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 28

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 28

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 28

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Lockdown of laptops 10 37
Deleting Computer From AD Still Lets me Login 1 22
ADFS 3.0 and UPN Problem 6 15
ACTIVE DIRECTORY 12 33
Follow this checklist to learn more about the 15 things you should never include in an email signature from personal quotes, animated gifs and out-of-date marketing content.
Marketers need statistics and metrics like everybody else needs oxygen. In this article we explain how to enable marketing campaign statistics for Microsoft Exchange mail.
In this video we show how to create an email address policy 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 Mail Flow…
To show how to create a transport rule 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 Mail Flow >> Rules tab.:  To cr…

705 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

19 Experts available now in Live!

Get 1:1 Help Now