Export Primary and Alias Email addresses in Exchange 2013

Is there a way to export a list of ALL mailbox Display Names, Primary SMTP Addresses and Alternate email addresses (Aliases) associated with the mailbox, BUT, this is where it may get tricky, have each of the alternate email address (SMTP,SIP, CCMail, MSMail, x400, x500, etc) exported to a separate CSV column?

Thanks in advance.
Christian HansAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Amit KumarCommented:
Please check this code, you can remove attributes those you don't need. it will give you all e-mail address are separated with ";"

Import-Module ActiveDirectory
Set-ADServerSettings -ViewEntireForest $true

$report = @()

if ($filename)
{
	$reportfile = $filename
}
else
{
	$timestamp = Get-Date -UFormat %Y%m%d-%H%M
	$random = -join(48..57+65..90+97..122 | ForEach-Object {[char]$_} | Get-Random -Count 6)
	$reportfile = "ExchangeReport-$timestamp-$random.csv"
}

$mbx1 = Get-Mailbox -resultsize unlimited

foreach ($mbx2 in $mbx1) 
	{

	$mbxdetails = Get-user -id $mbx2
			
	$Emailadd = [string]::join(";",$mbx2.EmailAddresses)
	$reportobj = New-Object PSObject
	$reportobj | Add-Member -MemberType NoteProperty -Name "FirstName" -Value $mbxdetails.FirstName -Force
	$reportobj | Add-Member -MemberType NoteProperty -Name "LastName" -Value $mbxdetails.LastName -Force
	$reportobj | Add-Member -MemberType NoteProperty -Name "StreetAddress" -Value $mbxdetails.StreetAddress -Force
	$reportobj | Add-Member -MemberType NoteProperty -Name "StateOrProvince" -Value $mbxdetails.StateOrProvince -Force
	$reportobj | Add-Member -MemberType NoteProperty -Name "PostalCode" -Value $mbxdetails.PostalCode -Force
	$reportobj | Add-Member -MemberType NoteProperty -Name "CountryOrRegion" -Value $mbxdetails.CountryOrRegion -Force
	$reportobj | Add-Member -MemberType NoteProperty -Name "Phone" -Value $mbxdetails.Phone -Force
	$reportobj | Add-Member -MemberType NoteProperty -Name "HomePhone" -Value $mbxdetails.HomePhone -Force
	$reportobj | Add-Member -MemberType NoteProperty -Name "MobilePhone" -Value $mbxdetails.MobilePhone -Force
	$reportobj | Add-Member -MemberType NoteProperty -Name "Fax" -Value $mbxdetails.Fax -Force
	$reportobj | Add-Member -MemberType NoteProperty -Name "Pager" -Value $mbxdetails.Pager -Force
	$reportobj | Add-Member -MemberType NoteProperty -Name "Department" -Value $mbxdetails.Department -Force
	$reportobj | Add-Member -MemberType NoteProperty -Name "Office" -Value $mbxdetails.Office -Force
	$reportobj | Add-Member -MemberType NoteProperty -Name "Title" -Value $mbxdetails.Title -Force
	$reportobj | Add-Member -MemberType NoteProperty -Name "WebPage" -Value $mbxdetails.WebPage -Force
	$reportobj | Add-Member -MemberType NoteProperty -Name "Notes" -Value $mbxdetails.Notes -Force
	$reportobj | Add-Member -MemberType NoteProperty -Name "EmailAddresses" -Value $Emailadd -Force
	$report = $report += $reportobj 
	$report | Export-Csv -path $reportfile -nti
	}
Write-Host -ForegroundColor "Yellow" -BackgroundColor "Red" "Script is completed."
Write-host -ForegroundColor "Green"  "Data has been written to $reportfile."

Open in new window

0
Christian HansAuthor Commented:
Thanks Amit. I am able to export the EmailAddresses attribute, the question is exporting them separately...

$reportobj | Add-Member -MemberType NoteProperty -Name "EmailAddresses" -Value $mailadd -Force

...would export them all to a single column.
0
Amit KumarCommented:
yes, if you want to separate them just play with excel and import only e-mail data with decimal separates ";", it will import that text data in separate columns in excel.

1. copy E-mail address columns data and paste it to notepad file
2. add more empty columns like 3-4.
3. then copy Text from notepad, then import that with decimal separator ";" semicolon. it will give you separate columns.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Exchange

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.