Need to extract Alias from email address

Hi all,

Need a quick help to find out the 300 alias in csv format by using email address. I have 300 email ids and i have to extract the alias of those email ids in csv format.
Advise me any script where i have to supply the email id in csv format and get their aliases .

Exchange 2010
Manish KumarSr. Technical ConsultantAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

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.

Tony JohncockLead Technical ArchitectCommented:
I can't try this as I am not currently sat in front of an Exchange shell but I think this should pull out what you are looking for (it is all one line):

Get-Mailbox  | Select-Object DisplayName,PrimarySmtpAddress, @{Name=“EmailAddresses”;Expression={$_.EmailAddresses |Where-Object {$_.PrefixString -ceq “smtp”} | ForEach-Object {$_.SmtpAddress}}} | Export-CSV .\alias.csv

The -ceq makes the smtp case-sensitive (as opposed to -eq which is case insensitive) so it should only return alias addresses.

The .\ is effectively saying "save the CSV in the same folder as the script is executed from" so you need to have actually have it saved somewhere before you run it (if you use say the PowerShell ISE).

Hope this works for you.

Edit: for details on how to read from your CSV, take a look at this MS discussion:

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
Manish KumarSr. Technical ConsultantAuthor Commented:
Hi All,

Thank you so much for your valuable inputs.
I don't need to find out the email address from all the accounts.
what i need is that
i have 300 different email addresses in an excel/csv file. I want to find out the alias of those email addresses only by using a script where the excel/csv file will work as input and i also need the result in excel/csv file.
Tony JohncockLead Technical ArchitectCommented:
See my post - you need to put a bit of work in yourself here because without knowing things like how your CSV is structured we cannot tell you how to read it.

For example do you have headings in the file?

If it's just a list of separated email addresses then something like this should do (note the change in bold):

$users = get-content file.csv

foreach ($email in $users)

Get-Mailbox  | Select-Object DisplayName,PrimarySmtpAddress, @{Name=“$Email”;Expression={$_.EmailAddresses |Where-Object {$_.PrefixString -ceq “smtp”} | ForEach-Object {$_.SmtpAddress}}} | Export-CSV .\alias.csv
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
Email Servers

From novice to tech pro — start learning today.