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:<\/p>\n
param<\/p>\n
(<\/p>\n
[Switch]$ExportMailboxSize,<\/p>\n
[Switch]$CompareMailboxSize,<\/p>\n
[String]$LogPath=“C:\\log”,<\/p>\n
[String<\/span>]$Identity,<\/p>\n [DateTime]$StartDate,<\/p>\n [DateTime]$EndDate<\/p>\n )<\/p>\n #region<\/span> Export today’s Mailbox Size<\/p>\n if ($ExportMailboxSize)<\/p>\n {<\/p>\n $Counter=0<\/p>\n $UserMailboxStatistics=@()<\/p>\n if(-not ( Test-Path -Path $LogPath))<\/p>\n {<\/p>\n New-Item -ItemType directory -Path $LogPath<\/p>\n }<\/p>\n #Get<\/span> mailbox identity<\/p>\n if (-not ($Identity))<\/p>\n {<\/p>\n $UserMailboxs=Get-Mailbox -Filter ‘RecipientTypeDetails -eq “UserMailbox”’ -ResultSize unlimited<\/p>\n }<\/p>\n else<\/p>\n {<\/p>\n $UserMailboxs=$Identity|Get-Mailbox -Filter ‘RecipientTypeDetails -eq “UserMailbox”’ -ResultSize unlimited<\/p>\n }<\/p>\n #Get<\/span> SamAccountName,DisplayName and MailboxTotalItemSize for specific users or all users with mailbox.<\/p>\n foreach ($UserMailbox in $UserMailboxs)<\/p>\n {<\/p>\n $Counter++<\/p>\n Write-Progress -Activity “Export MailboxStatistic” -Status “Exporting” -CurrentOperation $UserMailbox.DisplayName -PercentComplete ($counter/($UserMailboxs.Count)*100)<\/p>\n $UserMailboxStatistic = New-Object PSObject<\/p>\n $UserMailboxSizeB = (Get-MailboxStatistics -Identity $UserMailbox).TotalItemSize.Value.tobytes()<\/p>\n $UserMailboxSizeMB = “{0:#.##}” -f ($UserMailboxSizeB/1mb)<\/p>\n $UserMailboxStatistic | Add-Member -MemberType NoteProperty -Name “SamAccountName” -Value $UserMailbox.SamAccountName<\/p>\n $UserMailboxStatistic | Add-Member -MemberType NoteProperty -Name “DisplayName” -Value $UserMailbox.DisplayName<\/p>\n $UserMailboxStatistic | Add-Member -MemberType NoteProperty -Name “UserMailboxSizeMB” -Value $UserMailboxSizeMB<\/p>\n $UserMailboxStatistic | Add-Member -MemberType NoteProperty -Name “ItemsinFolder” -Value $ItemCount<\/p>\n $UserMailboxStatistics+=$UserMailboxStatistic<\/p>\n }<\/p>\n #Output<\/span> 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.<\/p>\n $UserMailboxStatistics|Export-Csv -Encoding default -NoTypeInformation -Path “$LogPath$(get-date -Format “yyyy-MM-dd”).csv”<\/p>\n }<\/p>\n #endregion<\/span><\/p>","upvoteCount":3,"answerCount":10,"datePublished":"2014-07-16T11:18:37.000Z","author":{"@type":"Person","name":"joshuanewby1972","url":"https://community.spiceworks.com/u/joshuanewby1972"},"acceptedAnswer":{"@type":"Answer","text":" Check this link, I think there is a simplest way to dot it, exactly how you want it.<\/p>\n Go thi where he say:<\/p>\n Finally, if I was interested in a report of the inbox sizes for all<\/em><\/p>\n mailboxes in the organizations, I would probably whip up a quick script<\/em><\/p>\n like this.<\/em><\/p>\n There is a picture of the result in a csv at the end.<\/p>\n http://exchangeserverpro.com/reporting-mailbox-folder-sizes-with-powershell/<\/a><\/p>","upvoteCount":2,"datePublished":"2014-07-16T11:37:14.000Z","url":"https://community.spiceworks.com/t/need-help-with-an-exchange-powershell-script/321742/2","author":{"@type":"Person","name":"micadam","url":"https://community.spiceworks.com/u/micadam"}},"suggestedAnswer":[{"@type":"Answer","text":" 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:<\/p>\n param<\/p>\n (<\/p>\n [Switch]$ExportMailboxSize,<\/p>\n [Switch]$CompareMailboxSize,<\/p>\n [String]$LogPath=“C:\\log”,<\/p>\n [String<\/span>]$Identity,<\/p>\n [DateTime]$StartDate,<\/p>\n [DateTime]$EndDate<\/p>\n )<\/p>\n #region<\/span> Export today’s Mailbox Size<\/p>\n if ($ExportMailboxSize)<\/p>\n {<\/p>\n $Counter=0<\/p>\n $UserMailboxStatistics=@()<\/p>\n if(-not ( Test-Path -Path $LogPath))<\/p>\n {<\/p>\n New-Item -ItemType directory -Path $LogPath<\/p>\n }<\/p>\n #Get<\/span> mailbox identity<\/p>\n if (-not ($Identity))<\/p>\n {<\/p>\n $UserMailboxs=Get-Mailbox -Filter ‘RecipientTypeDetails -eq “UserMailbox”’ -ResultSize unlimited<\/p>\n }<\/p>\n else<\/p>\n {<\/p>\n $UserMailboxs=$Identity|Get-Mailbox -Filter ‘RecipientTypeDetails -eq “UserMailbox”’ -ResultSize unlimited<\/p>\n }<\/p>\n #Get<\/span> SamAccountName,DisplayName and MailboxTotalItemSize for specific users or all users with mailbox.<\/p>\n foreach ($UserMailbox in $UserMailboxs)<\/p>\n {<\/p>\n $Counter++<\/p>\n Write-Progress -Activity “Export MailboxStatistic” -Status “Exporting” -CurrentOperation $UserMailbox.DisplayName -PercentComplete ($counter/($UserMailboxs.Count)*100)<\/p>\n $UserMailboxStatistic = New-Object PSObject<\/p>\n $UserMailboxSizeB = (Get-MailboxStatistics -Identity $UserMailbox).TotalItemSize.Value.tobytes()<\/p>\n $UserMailboxSizeMB = “{0:#.##}” -f ($UserMailboxSizeB/1mb)<\/p>\n $UserMailboxStatistic | Add-Member -MemberType NoteProperty -Name “SamAccountName” -Value $UserMailbox.SamAccountName<\/p>\n $UserMailboxStatistic | Add-Member -MemberType NoteProperty -Name “DisplayName” -Value $UserMailbox.DisplayName<\/p>\n $UserMailboxStatistic | Add-Member -MemberType NoteProperty -Name “UserMailboxSizeMB” -Value $UserMailboxSizeMB<\/p>\n $UserMailboxStatistic | Add-Member -MemberType NoteProperty -Name “ItemsinFolder” -Value $ItemCount<\/p>\n $UserMailboxStatistics+=$UserMailboxStatistic<\/p>\n }<\/p>\n #Output<\/span> 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.<\/p>\n $UserMailboxStatistics|Export-Csv -Encoding default -NoTypeInformation -Path “$LogPath$(get-date -Format “yyyy-MM-dd”).csv”<\/p>\n }<\/p>\n #endregion<\/span><\/p>","upvoteCount":3,"datePublished":"2014-07-16T11:18:37.000Z","url":"https://community.spiceworks.com/t/need-help-with-an-exchange-powershell-script/321742/1","author":{"@type":"Person","name":"joshuanewby1972","url":"https://community.spiceworks.com/u/joshuanewby1972"}},{"@type":"Answer","text":" That was exactly what I needed. Thank you!<\/p>","upvoteCount":0,"datePublished":"2014-07-16T11:51:19.000Z","url":"https://community.spiceworks.com/t/need-help-with-an-exchange-powershell-script/321742/3","author":{"@type":"Person","name":"joshuanewby1972","url":"https://community.spiceworks.com/u/joshuanewby1972"}},{"@type":"Answer","text":" 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.<\/p>\n Script:<\/p>\n $mailboxes = @(Get-Mailbox -ResultSize Unlimited)<\/p>\n $report = @()<\/p>\n foreach ($mailbox in $mailboxes)<\/p>\n {<\/p>\n $inboxstats = Get-MailboxFolderStatistics $mailbox -FolderScope Inbox | Where {$_.FolderPath -eq “/Inbox”}<\/p>\n $mbObj = New-Object PSObject<\/p>\n $mbObj | Add-Member -MemberType NoteProperty -Name “Display Name” -Value $mailbox.DisplayName<\/p>\n $mbObj | Add-Member -MemberType NoteProperty -Name “Inbox Size (Mb)” -Value $inboxstats.FolderandSubFolderSize.ToMB()<\/p>\n $mbObj | Add-Member -MemberType NoteProperty -Name “Inbox Items” -Value $inboxstats.ItemsinFolderandSubfolders<\/p>\n $report += $mbObj<\/p>\n }<\/p>\n $report<\/p>","upvoteCount":0,"datePublished":"2014-07-16T12:33:53.000Z","url":"https://community.spiceworks.com/t/need-help-with-an-exchange-powershell-script/321742/4","author":{"@type":"Person","name":"joshuanewby1972","url":"https://community.spiceworks.com/u/joshuanewby1972"}},{"@type":"Answer","text":" Apart from PS, You can have a look at this automated option available from Lepide i.e,( Software not available<\/a> ) 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.<\/p>","upvoteCount":0,"datePublished":"2014-07-17T02:44:36.000Z","url":"https://community.spiceworks.com/t/need-help-with-an-exchange-powershell-script/321742/5","author":{"@type":"Person","name":"allen-rich","url":"https://community.spiceworks.com/u/allen-rich"}},{"@type":"Answer","text":" Thanks, ill take a look at it.<\/p>","upvoteCount":0,"datePublished":"2014-07-17T10:03:15.000Z","url":"https://community.spiceworks.com/t/need-help-with-an-exchange-powershell-script/321742/6","author":{"@type":"Person","name":"joshuanewby1972","url":"https://community.spiceworks.com/u/joshuanewby1972"}},{"@type":"Answer","text":"