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.
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
.