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 we do in this example is create the $allusers
variable that stores an instance of the All Users
address list. We can then run the Get-Recipient
cmdlet and specify the OPATH filter, using the $allusers.RecipientFilter
object as the value...