?
Solved

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

Posted on 2012-09-06
7
Medium Priority
?
616 Views
Last Modified: 2012-09-11
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.
0
Comment
Question by:thelink12
  • 4
  • 3
7 Comments
 
LVL 52

Expert Comment

by:Manpreet SIngh Khatra
ID: 38374188
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
0
 

Author Comment

by:thelink12
ID: 38374215
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
0
 
LVL 52

Accepted Solution

by:
Manpreet SIngh Khatra earned 2000 total points
ID: 38374238
$info=@()
foreach($mbx in Get-Mailbox){
$info+=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
}
$info | export-csv -notypeinfo c:\info-result.csv

- Rancy
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:thelink12
ID: 38376030
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?
0
 
LVL 52

Expert Comment

by:Manpreet SIngh Khatra
ID: 38378768
Nothing coming to my mind as of now :(

- Rancy
0
 

Author Closing Comment

by:thelink12
ID: 38388137
This is a great start and I can tweak it as needed.
0
 
LVL 52

Expert Comment

by:Manpreet SIngh Khatra
ID: 38388144
If you got that 180 days and can share maybe can help and many others in the future :)

- Rancy
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Here in this article, you will get a step by step guidance on how to restore an Exchange database to a recovery database. Get a brief on Recovery Database and how it can be used to restore Exchange database in this section!
With so many activities to perform, Exchange administrators are always busy in organizations. If everything, including Exchange Servers, Outlook clients, and Office 365 accounts work without any issues, they can sit and relax. But unfortunately, it…
In this video we show how to create an Accepted Domain in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: First we need to log into the Exchange Admin Center. Navigate to the Mail Flow >> Ac…
In this video we show how to create a mailbox database in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: First we need to log into the Exchange Admin Center. Navigate to the Servers >> Data…
Suggested Courses

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question