I have a script here that I found online that will create a csv file that will show me each user inbox size and who it belongs to. I would like to add ItemsinFolder as a part of the report, and my knowledge of powershell is very limited. Below is the script:

param

(

[Switch]$ExportMailboxSize,

[Switch]$CompareMailboxSize,

[String]$LogPath=“C:\log”,

[String]$Identity,

[DateTime]$StartDate,

[DateTime]$EndDate

)

#region Export today’s Mailbox Size

if ($ExportMailboxSize)

{

$Counter=0

$UserMailboxStatistics=@()

if(-not ( Test-Path -Path $LogPath))

{

New-Item -ItemType directory -Path $LogPath

}

#Get mailbox identity

if (-not ($Identity))

{

$UserMailboxs=Get-Mailbox -Filter ‘RecipientTypeDetails -eq “UserMailbox”’ -ResultSize unlimited

}

else

{

$UserMailboxs=$Identity|Get-Mailbox -Filter ‘RecipientTypeDetails -eq “UserMailbox”’ -ResultSize unlimited

}

#Get SamAccountName,DisplayName and MailboxTotalItemSize for specific users or all users with mailbox.

foreach ($UserMailbox in $UserMailboxs)

{

$Counter++

Write-Progress -Activity “Export MailboxStatistic” -Status “Exporting” -CurrentOperation $UserMailbox.DisplayName -PercentComplete ($counter/($UserMailboxs.Count)*100)

$UserMailboxStatistic = New-Object PSObject

$UserMailboxSizeB = (Get-MailboxStatistics -Identity $UserMailbox).TotalItemSize.Value.tobytes()

$UserMailboxSizeMB = “{0:#.##}” -f ($UserMailboxSizeB/1mb)

$UserMailboxStatistic | Add-Member -MemberType NoteProperty -Name “SamAccountName” -Value $UserMailbox.SamAccountName

$UserMailboxStatistic | Add-Member -MemberType NoteProperty -Name “DisplayName” -Value $UserMailbox.DisplayName

$UserMailboxStatistic | Add-Member -MemberType NoteProperty -Name “UserMailboxSizeMB” -Value $UserMailboxSizeMB

$UserMailboxStatistic | Add-Member -MemberType NoteProperty -Name “ItemsinFolder” -Value $ItemCount

$UserMailboxStatistics+=$UserMailboxStatistic

}

#Output to a CSV file with date format “yyyy-MM-dd” as default name ,in default path “C:\log”. Path can be set by $logpath param.

$UserMailboxStatistics|Export-Csv -Encoding default -NoTypeInformation -Path “$LogPath$(get-date -Format “yyyy-MM-dd”).csv”

}

#endregion

3 Spice ups

Check this link, I think there is a simplest way to dot it, exactly how you want it.

Go thi where he say:

Finally, if I was interested in a report of the inbox sizes for all

mailboxes in the organizations, I would probably whip up a quick script

like this.

There is a picture of the result in a csv at the end.

http://exchangeserverpro.com/reporting-mailbox-folder-sizes-with-powershell/

2 Spice ups

That was exactly what I needed. Thank you!

Actually, I am looking through the results and I dont think the results are correct. I am showing some users that I know have a large inbox size, but show they have very low number of messages and small inbox size. I dont think this is taking in account subfolders that the user has created and moved. I need a total including their subfolders, inbox, sent, trash, etc.

Script:

$mailboxes = @(Get-Mailbox -ResultSize Unlimited)

$report = @()

foreach ($mailbox in $mailboxes)

{

$inboxstats = Get-MailboxFolderStatistics $mailbox -FolderScope Inbox | Where {$_.FolderPath -eq “/Inbox”}

$mbObj = New-Object PSObject

$mbObj | Add-Member -MemberType NoteProperty -Name “Display Name” -Value $mailbox.DisplayName

$mbObj | Add-Member -MemberType NoteProperty -Name “Inbox Size (Mb)” -Value $inboxstats.FolderandSubFolderSize.ToMB()

$mbObj | Add-Member -MemberType NoteProperty -Name “Inbox Items” -Value $inboxstats.ItemsinFolderandSubfolders

$report += $mbObj

}

$report

Apart from PS, You can have a look at this automated option available from Lepide i.e,( Software not available ) that can be a better alternate approach to get mailbox report with their sizes, contents, folder reports as well. With this email, you can also check how the mailbox sizes are growing in your environment.

Thanks, ill take a look at it.

@Allen, I installed Lepide and got it going with my SQL server, but it doesnt seem to want to act correctly. I can view user’s inbox, but no other data can be pulled, including the dashboard and reports?

@ Allen - Thanks for mentioning about Lepide’s tool.

@mmHelpdesk - I would request you to please have a look on

Software not available guide to check whether you have configured everything correctly or not.

Ok, I got it working. It was the full access permissions I was missing. Everything seems to be working, except for the Mailbox Size reports, which is what I need the most… Any ideas?

I would say this line is what’s limiting your report. Try changing it to this and see what you get.

$inboxstats = Get-MailboxFolderStatistics $mailbox -FolderScope Inbox

By specifying a FolderPath equal to /Inbox, you’re limiting your search to the actual Inbox. If that doesn’t work, change the FolderScope to All.