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) :
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:
As you know you can automate your application using .Net programmatically by referring the following articles:https://msdn.microsoft.com/en-us/library/bb332449(v=exchg.80).aspx and https://msdn.microsoft.com/en-us/library/ff326159(v=exchg.140).aspx.
Happy programming!!
Comments
Anonymous
December 11, 2013
Hi, How can we find single mail id or single mail message id which is in formate "0000003D762900000000003DDFD50000"? Thanks, Kiran!Anonymous
May 19, 2014
can i go against Get-Mailbox -organizationalunit and also output the mailbox attribute such as email address, display name ?Anonymous
December 15, 2014
what about the office365 archive folders, how do I access them?