Link to home
Start Free TrialLog in
Avatar of thelink12
thelink12

asked on

Export size of the "Sent" folder and "Deleted" folder in of all mailboxes in Exchange 2010 to Excel

I have an exchange script that I want to export the size of the sent folder and deleted folder for ALL mailboxes in the environment.  Exchange 2010.  I have tried this...

foreach($mbx in Get-Mailbox){
Get-MailboxFolderStatistics $mbx.identity -FolderScope deleteditems  | select @{n="DisplayName";e={$mbx.displayName}},FolderPath,ItemsInFolder,FolderSize
Get-MailboxFolderStatistics $mbx.identity -FolderScope sentitems  | select @{n="DisplayName";e={$mbx.displayName}},FolderPath,ItemsInFolder,FolderSize
}

and it seems to display everything on the screen fine.  What I want it to do is to export it to an excel spreadsheet so I can manipulate it.  I tried adding |export-csv but it didnt work.  It creates the .csv files but they are empty.

foreach($mbx in Get-Mailbox){ Get-MailboxFolderStatistics $mbx.identity -FolderScope deleteditems  | select @{n="DisplayName";e={$mbx.displayName}},FolderPath,ItemsInFolder,FolderSize | export-csv c:\deleted.csv
Get-MailboxFolderStatistics $mbx.identity -FolderScope sentitems  | select @{n="DisplayName";e={$mbx.displayName}},FolderPath,ItemsInFolder,FolderSize |
export-csv c:\sent.csv
}

I know this has to be easy, I just dont know what I am doing.
Avatar of Manpreet SIngh Khatra
Manpreet SIngh Khatra
Flag of India image

foreach($mbx in Get-Mailbox){
Get-MailboxFolderStatistics $mbx.identity -FolderScope deleteditems  | select @{n="DisplayName";e={$mbx.displayName}},FolderPath,ItemsInFolder,FolderSize
Get-MailboxFolderStatistics $mbx.identity -FolderScope sentitems  | select @{n="DisplayName";e={$mbx.displayName}},FolderPath,ItemsInFolder,FolderSize } > C:\Output.csv

or ever | Out-File C:\Output.csv

- Rancy
Avatar of thelink12
thelink12

ASKER

I am still not getting the correct output.  I ran the attached script from powershell on my workstation.  I watched the file get created and then I saw the size of the file fluctuate between 0 and 3 KB until the script was finally done and the attached excel document was what I got.  I apologize, I really know little about powershell.
exchang3.txt
temp.csv
ASKER CERTIFIED SOLUTION
Avatar of Manpreet SIngh Khatra
Manpreet SIngh Khatra
Flag of India image

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
Definite progress.  If I run this as it is written, I see the sent items in the console and the deleted items are exported to  a file.  If I switch replace "deleteditems" with "sentitems" and vice versa the output switches.  Deleted items to the console and sent items to the text file.  Is it easy to encorporate an age range in the sent items?  Say 180 days?
Nothing coming to my mind as of now :(

- Rancy
This is a great start and I can tweak it as needed.
If you got that 180 days and can share maybe can help and many others in the future :)

- Rancy