Skip to content

Commit

Permalink
Use generic list for performance
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Boonham authored and Chris Boonham committed Oct 18, 2024
1 parent 8e42a9e commit 33bf1c0
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions M365/Get-LargeMailboxFolderStatistics.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ param(
)

process {
$allContentFolders = New-Object System.Collections.Generic.List[System.Management.Automation.PSCustomObject]
$allContentFolders = New-Object System.Collections.Generic.List[object]
$start = Get-Date
Write-Host "$start Running Get-MailboxFolderStatistics for $Identity $MailboxType locations, in batches of $BatchSize"

Expand All @@ -54,7 +54,10 @@ 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 $Properties
[System.Array]$contentFolders = $batch | Where-Object { $_.ContentFolder -eq "TRUE" } | Select-Object -Property $Properties
if ($contentFolders.Count -gt 0) {
$allContentFolders.AddRange($contentFolders)
}
Write-Host "$(Get-Date):$loopCount Found $($batch.Count) content folders from $($location.MailboxLocationType):$($location.MailboxGuid)"
$loopCount += 1
}
Expand Down

0 comments on commit 33bf1c0

Please sign in to comment.