Comments on: Reporting Mailbox Folder Sizes with PowerShell https://practical365.com/reporting-mailbox-folder-sizes-with-powershell/ Practical Office 365 News, Tips, and Tutorials Fri, 09 Feb 2024 22:49:07 +0000 hourly 1 https://wordpress.org/?v=6.6.1 By: <div class="apbct-real-user-wrapper"> <div class="apbct-real-user-author-name">Tony Redmond</div> <div class="apbct-real-user-badge" onmouseover=" let popup = document.getElementById('apbct_trp_comment_id_287229'); popup.style.display = 'inline-flex'; "> <div class="apbct-real-user-popup" id="apbct_trp_comment_id_287229"> <div class="apbct-real-user-title"> <p class="apbct-real-user-popup-header">The Real Person!</p> <p class="apbct-real-user-popup-text">Author <b>Tony Redmond</b> acts as a real person and passed all tests against spambots. Anti-Spam by CleanTalk.</p> </div> </div> </div> </div> https://practical365.com/reporting-mailbox-folder-sizes-with-powershell/#comment-287229 Fri, 09 Feb 2024 22:49:07 +0000 https://www.practical365.com/?p=6184#comment-287229 In reply to Cathryn.

I don’t have an on-premises Exchange server any more, but this code works for Exchange Online. I don’t recommend creating a complex set of piped cmdlets because it makes it awfully difficult to understand code (at times) and creates a support issue going forward.

$Report = [System.Collections.Generic.List[Object]]::new()
[array]$Mailboxes = Get-Mailbox -RecipientTypeDetails UserMailbox -ResultSize Unlimited | Sort-Object DisplayName
ForEach ($Mbx in $Mailboxes) {
$Stats = Get-MailboxStatistics -Identity $Mbx.Alias
[float]$MbxSizeGB = [math]::Round(($Stats.TotalItemSize.value.ToString().Split(“(“)[1].Split(” “)[0].Replace(“,”,””)/1024MB),2)
If ($MbxSizeGB -gt 50 ) {
$FolderStats = Get-MailboxFolderStatistics -Identity $Mbx.Alias -IncludeOldestAndNewestItems | `
Select-Object Name, OldestItemReceivedDate | Sort-Object OldestItemReceivedDate | `
Where-Object OldestItemReceiveddate -ne $null | Select-Object -First 1
$ReportLine = [PSCustomObject][Ordered]@{
Mailbox = $Mbx.displayName
‘Size GB’ = $MbxSizeGB
Folder = $FolderStats.name
‘Oldest item’ = $FolderStats.OldestItemReceivedDate
}
$Report.Add($ReportLine)
}
}

$Report | Out-GridView

]]>
By: Cathryn https://practical365.com/reporting-mailbox-folder-sizes-with-powershell/#comment-287225 Fri, 09 Feb 2024 22:01:37 +0000 https://www.practical365.com/?p=6184#comment-287225 So, I have been fiddling with your script to do the following:
Get the Username, OU with a specific format, and TotalItemSize in GB for all mailboxes over 50GB and then for each user in that list get the MailboxFolderStatistics including Oldest and Newest Items for only the single OldestItemReceivedDate and the foldername where that oldest item resides and export that to a .csv
The first part runs spectacularly and pulls what I’m looking for. Where I’m having a problem is getting the Oldest Item Received Date and Folder Name to input into the second part and then exporting that to a .csv file.

This is what I have so far – Any help is much appreciated!
$mailboxes = @(Get-Mailbox -ResultSize Unlimited | Get-MailboxStatistics | Where-Object { $_.TotalItemSize -gt “50GB” } | Select DisplayName, @{expression={(Get-Recipient $_.DisplayName).OrganizationalUnit};name=”OrganizationalUnit”}, @{label=”TotalItemSize”;expression={[math]::Round(($_.TotalItemSize.value.ToString().Split(“(“)[1].Split(” “)[0].Replace(“,”,””)/1024MB),2)}})
$report = “C:\Reports\Exchange\Test.csv”
foreach ($mailbox in $mailboxes)
{
$inboxstats = Get-MailboxFolderStatistics $mailbox.DisplayName -IncludeOldestAndNewestItems | Select FolderName, OldestItemReceivedDate | Sort OldestItemReceivedDate | Where OldestItemReceiveddate -ne $null | Select-Object -First 1

$mbObj = New-Object PSObject
$mbObj | Add-Member -MemberType NoteProperty -Name “DisplayName” -Value $mailbox.DisplayName
$mbObj | Add-Member -MemberType NoteProperty -Name “OU” -Value $mailbox.OrganizationalUnit
$mbObj | Add-Member -MemberType NoteProperty -Name “TotalItemSize(GB)” -Value $mailbox.TotalItemSize
$mbObj | Add-Member -MemberType NoteProperty -Name “FolderName” -Value $inboxstats.Name
$mbObj | Add-Member -MemberType NoteProperty -Name “OldestItem” -Value $inboxstats.OldestItemReceivedDate
$report += $mbObj
}
$report

]]>
By: Spain https://practical365.com/reporting-mailbox-folder-sizes-with-powershell/#comment-265012 Fri, 02 Jun 2023 15:24:01 +0000 https://www.practical365.com/?p=6184#comment-265012 thank you
I have improve your script with two lines

echo $mailbox.PRIMARYSMTPADDRESS
$inboxstats = Get-MailboxFolderStatistics $mailbox.PRIMARYSMTPADDRESS

]]>
By: <div class="apbct-real-user-wrapper"> <div class="apbct-real-user-author-name">Tony Redmond</div> <div class="apbct-real-user-badge" onmouseover=" let popup = document.getElementById('apbct_trp_comment_id_247522'); popup.style.display = 'inline-flex'; "> <div class="apbct-real-user-popup" id="apbct_trp_comment_id_247522"> <div class="apbct-real-user-title"> <p class="apbct-real-user-popup-header">The Real Person!</p> <p class="apbct-real-user-popup-text">Author <b>Tony Redmond</b> acts as a real person and passed all tests against spambots. Anti-Spam by CleanTalk.</p> </div> </div> </div> </div> https://practical365.com/reporting-mailbox-folder-sizes-with-powershell/#comment-247522 Fri, 25 Nov 2022 11:55:46 +0000 https://www.practical365.com/?p=6184#comment-247522 In reply to Nikhil.

Inactive mailboxes are inactive. The Get-MailboxStatistics cmdlet (or Get-ExoMailboxStatistics) doesn’t support inactive mailboxes.

]]>
By: Nikhil https://practical365.com/reporting-mailbox-folder-sizes-with-powershell/#comment-247497 Fri, 25 Nov 2022 00:10:08 +0000 https://www.practical365.com/?p=6184#comment-247497 Can we fetch inactive mailbox folder statistics? If yes, could you please help me?

]]>
By: Mahendra Reddy https://practical365.com/reporting-mailbox-folder-sizes-with-powershell/#comment-242510 Wed, 31 Aug 2022 12:05:37 +0000 https://www.practical365.com/?p=6184#comment-242510 In reply to Gregor.

Please export the user’s alias to a CSV file with the below CMD:

Get-Mailbox | ft Displayname, Alias >C:\Temp\userlist.csv

Then use the below CMD and get the contacts per user:

Import-Csv C:\Temp\userlist.csv | ForEach {Get-MailboxFolderStatistics -identity $_.Alias -FolderScope Contacts | Where {$_.FolderPath -eq “/Contacts”} | Select Name,FolderandSubFolderSize,ItemsinFolderandSubfolders } >C:\Temp\users_contacts.csv

Later you can merge the data in both the excel files to get the final report.

]]>
By: <div class="apbct-real-user-wrapper"> <div class="apbct-real-user-author-name">Tony Redmond</div> <div class="apbct-real-user-badge" onmouseover=" let popup = document.getElementById('apbct_trp_comment_id_238540'); popup.style.display = 'inline-flex'; "> <div class="apbct-real-user-popup" id="apbct_trp_comment_id_238540"> <div class="apbct-real-user-title"> <p class="apbct-real-user-popup-header">The Real Person!</p> <p class="apbct-real-user-popup-text">Author <b>Tony Redmond</b> acts as a real person and passed all tests against spambots. Anti-Spam by CleanTalk.</p> </div> </div> </div> </div> https://practical365.com/reporting-mailbox-folder-sizes-with-powershell/#comment-238540 Thu, 19 May 2022 09:07:07 +0000 https://www.practical365.com/?p=6184#comment-238540 In reply to Brian.

If you have a defined set of folders that you need to grab information for, you can use the Graph API to fetch the folders and then parse them to find the target set (like I do for the Inbox in https://office365itpros.com/2022/05/19/mailbox-folder-statistics/). After that, it’s a matter of straightforward PowerShell to grab the statistics for those folders. Using the Graph with PowerShell is much faster than trying to do this with Get-ExoMailboxFolderStatistics…

]]>
By: Brian https://practical365.com/reporting-mailbox-folder-sizes-with-powershell/#comment-237029 Mon, 08 Nov 2021 20:38:11 +0000 https://www.practical365.com/?p=6184#comment-237029 How do I get size and item info for User Created folders and subfolders only? I can see the folders when I run get-mailboxfolderstatistics however I need to target a set of user created folders for the entire organization. I have over 18000 users I cant run a basic command and then parse the info out I need to get the folder info directly from my powershell command…is it even possible?

]]>
By: Alain Sylvestre https://practical365.com/reporting-mailbox-folder-sizes-with-powershell/#comment-231119 Thu, 03 Sep 2020 14:37:29 +0000 https://www.practical365.com/?p=6184#comment-231119 HI,

Is that script working with microsoft 365 today ?

]]>
By: Jarno Jonkman https://practical365.com/reporting-mailbox-folder-sizes-with-powershell/#comment-229575 Tue, 19 May 2020 07:01:10 +0000 https://www.practical365.com/?p=6184#comment-229575 Good morning, ,

Does anyone know a solution for me?

There are a number of users of exchange 2016 where the mailbox is too big.
I want to reduce this, and now i would like an output (*csv) which contains the senders (or domains) and the total mb’s of the senders.
I can’t so far, can anyone help?

Thank you in advance
Jarno

]]>