List mailbox attributes to a customer is a recurring task.
The following script will provide a comprehensive list of the most relevant mailbox attributes and exported it to a .CSV file.
It will list the attributes expanded without the values being cut off by an ellipsis ( … ) as Exchange displays it by default.
List Mailbox Attributes Powershell Script
# List Mailbox Attributes PS Script
# Written by WebBanshee
# Feel free to use
#———————————————
#Define OrganizationalUnit
$customer = “OrgUnitName”
#Define certain customer domain within OrganizationalUnit / !! Comment out for results on all mailboxes within the OrganizationalUnit !!
$domain =”*DomainName*”
#CSV header , query mailbox attributes , define output
$output = “Alias;UserPrincipalName;DisplayName;PrimarySMTPAddress;FWSmptAddress;FWAddress;LegacyExchangeDN;EmailAddresses”
$org = get-mailbox -OrganizationalUnit $customer | Where-object {$_.PrimarySmtpAddress -like $domain}| Sort-Object Alias
$CustomerFile = “\\Fileshare\Folder\” + $Customer + “.csv”
$output > $CustomerFile
#Loop through mailboxes and provide results
foreach ( $mailbox in $org )
{
$FormatEnumerationLimit = -1
$Mailbox | Select-Object Alias,UserPrincipalName,DisplayName,PrimarySmtpAddress,ForwardingSmtpAddress,ForwardingAddress,LegacyExchangeDN,EmailAddresses
$output = $mailbox.Alias + “;” + $mailbox.UserPrincipalname + “;” + $mailbox.DisplayName + “;” + $mailbox.PrimarySmtpAddress + “;” + $mailbox.ForwardingSmtpAddress + “;” + $mailbox.ForwardingAddress + “;” + $mailbox.LegacyExchangeDN + “;” + $mailbox.EmailAddresses
$output >> $CustomerFile
}
I recommend leaving the EmailAddresses attribute at the end of the query. ( As it is right now )
This is because Excel breaks the .csv formatting when a result with many characters is displayed in a column somewhere in the middle.
Results will be displayed for these attributes in the following order :
Alias; UserPrincipalName; DisplayName; PrimarySMTPAddress; ForwardingSMTPAddress; ForwardingAddress; LegacyExchangeDN; EmailAddresses
You can find a description on how to expand all details in PowerShell here :
Expand powershell output to display all items
It could come in handy when you are in need of this kind of result.