Last active
December 30, 2020 16:26
-
-
Save bill-long/16cb823a6e58d5aa4ad86edb72d32b7b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
param($Database, $SaveResults) | |
. $exscripts\ManagedStoreDiagnosticFunctions.ps1 | |
if ($null -eq (Get-Command Get-StoreQuery -ErrorAction SilentlyContinue)) { | |
Write-Error "ManagedStoreDiagnosticFunctions not loaded." | |
return | |
} | |
$results = @() | |
$mailboxes = Get-StoreQuery -Database $Database -Query "Select MailboxNumber,DisplayName from Mailbox" -Unlimited | |
$count = 0 | |
$mailboxes | ForEach-Object { | |
$count++ | |
Write-Progress -Activity "Counting indexes" -PercentComplete ($count * 100 / $mailboxes.Count) -CurrentOperation $_.DisplayName | |
$indexes = @(Get-StoreQuery -Database $Database -Query "Select * from PseudoIndexControl where MailboxPartitionNumber = $($_.MailboxNumber)" -Unlimited) | |
$outputObject = [PSCustomObject]@{ | |
MailboxNumber = $_.MailboxNumber | |
DisplayName = $_.DisplayName | |
IndexCount = $indexes.Count | |
} | |
$results += $outputObject | |
$outputObject | |
} | |
$results = $results | Sort-Object MailboxNumber | |
$timeString = [DateTime]::Now.ToString("yyyyMMddHHmmss") | |
$fileName = "PhysicalIndexCount-$timeString.csv" | |
if ($SaveResults) { | |
$results | Export-Csv "$PSScriptRoot\$fileName" -NoTypeInformation | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment