Exchange PowerShell: How to get list of mailboxes, folders, subfolders, items in folder, foldersize programmatically?


One of my customer automated Exchange PowerShell with his .Net application. They had a requirement to enhance the functionality – to get the list of exchange mailboxes, folders and its sub folders, items in folder, foldersize. Finally it needs to be saved in .csv format. 
To implement this, we used Get-Mailbox and Get-MailboxFolderStatistics Exchange cmdlets. For looping the objects, we used foreach-object and couple of pipes to achieve the goal.

PowerShell (screenshot):

Exchange PowerShell

PowerShell (script) – adding for your reference:

[PS] C:\Documents and Settings\Administrator>Get-Mailbox | Select-Object alias | foreach-object {Get-MailboxFolderStatistics -Identity $_.alias | select-object Identity, ItemsInFolder, FolderSize} | Export-csv c:\Stats.csv -NoTypeInformation

Result:

Output

As you know you can automate your application using .Net programmatically by referring the following articles:http://msdn.microsoft.com/en-us/library/bb332449(v=exchg.80).aspx and http://msdn.microsoft.com/en-us/library/ff326159(v=exchg.140).aspx.

Happy programming!!

Comments (3)
  1. kirandudala says:

    Hi,

    How can we find single mail id or single mail message id which is in formate "0000003D762900000000003DDFD50000"?

    Thanks,

    Kiran!

  2. Jimmy says:

    can i go against Get-Mailbox -organizationalunit and also output the mailbox attribute such as email address, display name ?

  3. alindzon says:

    what about the office365 archive folders, how do I access them?

Comments are closed.