Exporting address list membership to a CSV file

When it comes to working with address lists, a common task is exporting the list of members to an external file. In this recipe, we'll take a look at the process of exporting the contents of an address list to a CSV file.

How to do it...

Let's start off with a simple example. The following commands will export the All Users address list to a CSV file:

$allusers = Get-AddressList "All Users"
Get-Recipient -RecipientPreviewFilter $allusers.RecipientFilter | 
  Select-Object DisplayName,Database | 
    Export-Csv -Path c:\allusers.csv -NoTypeInformation

When the command completes, a list of user display names and their associated mailbox databases will be exported to c:\allusers.csv.

How it works...

The first thing ...

Get Microsoft Exchange 2010 PowerShell Cookbook now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.