Exporting mailbox information to CSV for one particular domain or one OU

Hello,

I have an Exchange 2013 server which handles email for about 5 different domains.
I need to export to PST all mailboxes for one of these domains.

Part 1.
1.I would like to first gather the following in CSV: Name of User | Email Address | Mailbox Size
2.I've tried various commands exporting to details to CSV, but when I open the CSV, I find that all the data is in a single cell rather than separate columns.  Can you furnish the appropriate command to address this issue?

Part 2
1.Also is it possible to export this information only for mailboxes with the particular email domain (all users whose email address ends with domain2.com?
2.Can it export information only from one particular Organization Unit?

Thanks in advance.

Regards,
Real-Timer
realtimerAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

timgreen7077Exchange EngineerCommented:
Try the below. This should give you what you need.

$DataPath = "C:\temp\results.csv"
$Results = @()
$MailboxUsers = get-mailbox -resultsize unlimited | where {$_.organizationalunit -like "Enter the OU Path"}
foreach($user in $mailboxusers)
{
$UPN = $user.UserPrincipalName
$MbxStats = Get-MailboxStatistics $UPN
$UserNotes = Get-User $UPN
      $Properties = @{
      Name = $user.name
      UPN = $UPN
      Alias = $user.alias
      OU = $user.organizationalunit
      Server = $MbxStats.servername
      Database = $MbxStats.databasename
      TotaItemSize = $MbxStats.totalitemsize
      }
$Results += New-Object psobject -Property $properties
}
$Results | Sort-Object -Property TotaItemSize | Select-Object Name,UPN,Alias,OU,Server,Database,TotaItemSize | Export-Csv -notypeinformation -Path $DataPath
2

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Exchange

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.