Link to home
Start Free TrialLog in
Avatar of Mr Woober
Mr WooberFlag for Norway

asked on

Exchange Powershell - How to get emailaddress

Tired of searching and testing and failing. Assume this would be an very easy one :)

get-mailbox | get-mailboxstatistics | select displayname,TotalItemSize,LastLogonTime,PrimarySmtpAddress

This is the thing i need. But having trouble getting the email address to the select. How can this be done in an easy way ?

Also looked at :
$Mailboxes = Get-Mailbox -ResultSize Unlimited
foreach ($Mailbox in $Mailboxes)
{
$Mailbox | Add-Member -MemberType "NoteProperty" -Name "MailboxSizeMB" -Value ((Get-MailboxStatistics $Mailbox).TotalItemSize.Value.ToMb())
}
$Mailboxes | Sort-Object MailboxSizeMB -Desc | Select MailboxSizeMB,TotalItemSize,Count | Export-Csv -NoType "C:\temp\Mailboxessize.csv"


Any suggestions ?
Avatar of sirbounty
sirbounty
Flag of United States of America image

get-mailbox | select emailaddresses
should get you the mail address
$Mailboxes = Get-Mailbox -ResultSize Unlimited
foreach ($Mailbox in $Mailboxes)
{
$obj = new-object psobject
$obj | Add-Member -MemberType "NoteProperty" -Name "MailboxSizeMB" -Value ((Get-MailboxStatistics $Mailbox).TotalItemSize.Value.ToMb())
$obj | add-member noteproperty Email -value $mailbox.emailaddresses
write-output $obj
}

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Minecraft_ Enderman
Minecraft_ Enderman

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
You could get away with

get-mailbox | export-csv c:\test.csv

or

get-mailbox | get-mailboxstatistics | select DisplayName,ItemCount,TotalItemSize | export-csv "MailboxSizes.csv"