Skip to content

Commit

Permalink
Address code review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Boonham authored and Chris Boonham committed Oct 17, 2024
1 parent 854bf81 commit 74f90a8
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.

#Requires -Modules @{ ModuleName="ExchangeOnlineManagement"; RequiredVersion="3.4.0" }

<#
.SYNOPSIS
Retrieves folder statistics for mailboxes with large numbers of folders.
Expand All @@ -25,7 +27,7 @@
.EXAMPLE
$folderStats = .\Get-LargeMailboxFolderStatistics.ps1 -Identity [email protected]
$folderStats = .\Get-LargeMailboxFolderStatistics.ps1 -Identity [email protected] -MailboxType Primary
$folderStats = .\Get-LargeMailboxFolderStatistics.ps1 -Identity [email protected] -MailboxType Archive -BatchSize 5000 -Properties "Name, FolderPath"
$folderStats = .\Get-LargeMailboxFolderStatistics.ps1 -Identity [email protected] -MailboxType Archive -BatchSize 5000 -Properties @("Name", "FolderPath")
#>
param(
[Parameter(Mandatory = $true, Position = 0)]
Expand All @@ -40,8 +42,7 @@ param(
)

Process {
$allContentFolders = $null
$propertyArray = $Properties -split ',' | ForEach-Object { $_.Trim() }
$allContentFolders = New-Object System.Collections.Generic.List[System.Management.Automation.PSCustomObject]
$start = Get-Date
Write-Host "$start Running Get-MailboxFolderStatistics for $Identity $MailboxType locations, in batches of $BatchSize"

Expand All @@ -53,7 +54,7 @@ Process {
do {
$skipCount = $BatchSize * $loopCount
$batch = Get-MailboxFolderStatistics -Identity $($location.Identity) -ResultSize $batchSize -SkipCount $skipCount
$allContentFolders += $batch | Where-Object { $_.ContentFolder -eq "TRUE" } | Select-Object -Property $propertyArray
$allContentFolders += $batch | Where-Object { $_.ContentFolder -eq "TRUE" } | Select-Object -Property $Properties
Write-Host "$(Get-Date):$loopCount Found $($batch.Count) content folders from $($location.MailboxLocationType):$($location.MailboxGuid)"
$loopCount += 1
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ $folderStats = .\Get-LargeMailboxFolderStatistics.ps1 -Identity [email protected]

Example to get the mailbox folder statistics for a Archive mailbox, in batches of 5000 and just the folder properties Name and FolderPath
```PowerShell
$folderStats = .\Get-LargeMailboxFolderStatistics.ps1 -Identity [email protected] -MailboxType Archive -BatchSize 5000 -Properties "Name, FolderPath"
$folderStats = .\Get-LargeMailboxFolderStatistics.ps1 -Identity [email protected] -MailboxType Archive -BatchSize 5000 -Properties @("Name", "FolderPath")
```


Expand Down
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ nav:
- MDO:
- MDOThreatPolicyChecker: M365/MDO/MDOThreatPolicyChecker.md
- DLT365Groupsupgrade: M365/DLT365Groupsupgrade.md
- Get-LargeMailboxFolderStatistics: M365/Get-LargeMailboxFolderStatistics.md
- Performance:
- ExPerfWiz: Performance/ExPerfWiz.md
- ExPerfAnalyzer: Performance/ExPerfAnalyzer.md
Expand Down

0 comments on commit 74f90a8

Please sign in to comment.