Jump to content

Exporting email addresses to CSV for users in specific database - Exchange 2010


Recommended Posts

Posted (edited)

Hi,

 

I have been asked to give someone a list of all staff email addresses and I believe there is a way to export them from exchange 2010 to a csv file. I have managed to export all users to a CSV using PowerShell, but how do I do it from a specific database only (staff)? Going through 1500+ users to pick staff out is going to be a nightmare. I need a way of extracting them from a specific database or organisational title.

 

Is this possible?

 

I tried this but it didn't work

 

Get-Mailbox -Database "MCA-SR-EX1\MCA Staff.edb" -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
It returns an error relating to the database line (is not a valid value for the identity) Edited by Darylrese
Posted (edited)
Get-Mailbox * -ResultSize Unlimited | where-object {$_.Database -eq "Staff"} | export-csv c:\tmp\mailbox.csv Edited by pcstru
Posted (edited)

The only thing wrong with your query is that the value of Database should be the display name not that path.

 

Get-Mailbox -Database "MCA Staff" -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

 

For example.

Edited by ChrisMiles
  • Thanks 1
Posted
The only thing wrong with your query is that the value of Database should be the display name not that path.

 

Get-Mailbox -Database "MCA Staff" -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

 

For example.

 

This worked perfectly, thank-you! I'm sure I tried this before but obviously I didn't!

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...