Link to home
Start Free TrialLog in
Avatar of osiexchange

asked on

Trying to find out total of all users Deleted Items folders

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.
Avatar of Hendrik Wiese
Hendrik Wiese
Flag of South Africa image

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

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
Avatar of osiexchange


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
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Get-MailboxFolderStat
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
Avatar of Hendrik Wiese
Hendrik Wiese
Flag of South Africa image

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
That worked great. Thanks!!
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
Is it possible to output this particular command? I really need this in an Excel spreadsheet to make it useful.
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