Trying to find out total of all users Deleted Items folders

osiexchange
osiexchange used Ask the Experts™
on
Is there a powershell script that will get the size of all my users Deleted Items folders? I am not interested in the Recoverable Deleted Items, just the actual Deleted Items folder. Reason I ask is we are having disk space issues and I think most users are just Deleting Items but not empyting their Deleted Items folder. I know I can use managed folders to take care of this but for now, I am just curious as to the grand total of every users Deleted Items folder. I have run Powershell scripts to output mailbox size but I don't know if you can refine it to just get the size of a particular folder. If not, is there a perfmon counter that would have this data.We are running Exchange 2010 SP1 with update rollup 3.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Hendrik WieseInformation Security Manager

Commented:
Try the following which will export the sizes to TEST.csv and you can use excel to calculate the total size:

Get-Mailbox | foreach {
   $mbx = $_.DisplayName
   Get-MailboxFolderStatistics $_.identity -FolderScope 'DeletedItems' | select @{n="DisplayName";e={$mbx.displayName}},FolderPath,ItemsInFolder,@{n="FolderSize(MB)";e={$_.folderSize.toMB()}}
} | export-csv c:\TEST.csv

Hendrik WieseInformation Security Manager

Commented:
Sorry the above script had some syntax issues run the following one:

$mbx = $_.DisplayName;
   Get-MailboxFolderStatistics $_.identity -FolderScope 'DeletedItems' | select @{n="DisplayName";e={$mbx}},FolderPath,ItemsInFolder,@{n="FolderSize(MB)";e={$_.folderSize.toMB()}}
} | export-csv c:\TEST.csv

Author

Commented:
Thanks. I am getting the error below. Note I left off the | export command at the end to simplify for now.


Cannot bind argument to parameter 'Identity' because it is null.
    + CategoryInfo          : InvalidData: (:) [Get-MailboxFolderStatistics], ParameterBindingVali
   dationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Get-MailboxFolderStat
   istics
Success in ‘20 With a Profitable Pricing Strategy

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

Author

Commented:
Getting close. See below

Unexpected token '}' in expression or statement.
At line:1 char:181
+    Get-MailboxFolderStatistics $_.identity -FolderScope 'DeletedItems' | select @{n="DisplayName"
;e={$mbx}},FolderPath,ItemsInFolder,@{n="FolderSize(MB)";e={$_.folderSize.toMB()}}} <<<<
    + CategoryInfo          : ParserError: (}:String) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : UnexpectedToken
Information Security Manager
Commented:
This would be because of the '. Copy the following script to notepad and then cut it from notepad and paste it into your power shell:

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

Author

Commented:
That worked great. Thanks!!

Author

Commented:
Excellent!

Author

Commented:
Just one more question. I am now trying to pipe to a csv file. I tried the |out-file switch and the export-csv switch but I am getting the error below.

An empty pipe element is not allowed.
At line:1 char:187
+ foreach($mbx in Get-Mailbox){Get-MailboxFolderStatistics $mbx.identity -FolderScope 'DeletedItems
' | select @{n="DisplayName";e={$mbx.displayName}},FolderPath,ItemsInFolder,FolderSize} | <<<< expo
rt-csv c:\deleteditems.csv
    + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : EmptyPipeElement

Author

Commented:
Is it possible to output this particular command? I really need this in an Excel spreadsheet to make it useful.
Seelan NaidooMicrosoft Systems Admin

Commented:
try this one..


$result=foreach($mbx in Get-Mailbox){Get-MailboxFolderStatistics $mbx.identity -FolderScope 'DeletedItems' |
select @{n="DisplayName";e={$mbx.displayName}},FolderPath,ItemsInFolder,FolderSize}
$result | Export-csv C:\Scripts\Folderstats.csv -notype

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial