Solved

List all email addresses in Exchange 2010 including any forward emails

Posted on 2013-12-18
5
503 Views
Last Modified: 2014-06-27
I need to modify the following scripts so that any emails which have forwards associated with them will also be shown:

Get-recipient -resultsize unlimited | select Name -expand emailaddresses | Select SmtpAddress

or

Get-Mailbox -ResultSize Unlimited |Select-Object DisplayName,ServerName,PrimarySmtpAddress, @{Name=“EmailAddresses”;Expression={$_.EmailAddresses |Where-Object {$_.PrefixString -ceq “smtp”} | ForEach-Object {$_.SmtpAddress}}} > C:\Addresses\emailaddresses.txt

or

Get-recipient -ResultSize Unlimited |Select-Object DisplayName,ServerName,PrimarySmtpAddress, @{Name=“EmailAddresses”;Expression={$_.EmailAddresses |Where-Object {$_.PrefixString -ceq “smtp”} | ForEach-Object {$_.SmtpAddress}}} | Export-Csv c:\mailbox_alias.csv
0
Comment
Question by:100questions
  • 3
  • 2
5 Comments
 
LVL 12

Expert Comment

by:Vaseem Mohammed
ID: 39734402
I came up with this script for you.
Tested it in my environment and the results are as expected, give output on screen as well in a csv format which includes Name, Alias and forward Address associated to each account.

Hope it help.

$report = @()

$MBColl = Get-Mailbox -ResultSize Unlimited | where{$_.ForwardingAddress -ne $null }
foreach($MB in $MBColl){

    $FFAddrFQDN = $MB.ForwardingAddress
    $FFAddr = Get-MailContact -Identity "$FFAddrFQDN"

    $objA = new-object psobject
    $objA | Add-Member NoteProperty -Name "User Name" -Value $MB.Name
    $objA | Add-Member NoteProperty -Name "Alias" -Value $MB.Alias
    $objA | Add-Member NoteProperty -Name "Forward Address" -Value $FFAddr.PrimarySMTPAddress

    $report = $report += $objA
    }
 $report | FT

 $report | Export-Csv -Path c:\Get-ForwardAddress-Report.csv -NoTypeInformation

Open in new window

0
 

Author Comment

by:100questions
ID: 39756016
Is this an Exchange script?  If yes, how to  you run it?
0
 
LVL 12

Expert Comment

by:Vaseem Mohammed
ID: 39756956
Yes, its a script that need to be run from "Exchange Management Shell"EMS1Copy the script into a notepad and "Save as" name it as u like but put the name in quotes "" with file extension as ".ps1"save asUsing Exchange Management Shell, browse to the directory where you saved the file and type .\Get-ForwardingAddress.sp1
Note that the output will seen in EMS as well as .csv file will be saved on C drive.
You can change the path in the very last line of script.
0
 
LVL 12

Accepted Solution

by:
Vaseem Mohammed earned 500 total points
ID: 39765278
any help needed?
0
 

Author Closing Comment

by:100questions
ID: 40163165
Might work, I need to ask a question.
0

Featured Post

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

Issue: One Windows 2008 R2 64bit server on the network unable to connect to a buffalo Device (Linkstation) with firmware version 1.56. There are a total of four servers on the network this being one of them. Troubleshooting Steps: Connect via h…
If you get continual lockouts after changing your Active Directory password, there are several possible reasons.  Two of the most common are using other devices to access your email and stored passwords in the credential manager of windows.
Windows 8 comes with a dramatically different user interface known as Metro. Notably missing from the new interface is a Start button and Start Menu. Many users do not like it, much preferring the interface of earlier versions — Windows 7, Windows X…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

830 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