Skip to content

Commit 6741d8f

Browse files
CopilotShanefe
andauthored
Fix unary commas in Convert-AppointmentRecurrenceBlobToBytes and preserve RAW order in BuildCSV dedup
Agent-Logs-Url: https://github.com/microsoft/CSS-Exchange/sessions/a475f1cd-4da3-4c2b-866d-22353ec0a42a Co-authored-by: Shanefe <6235087+Shanefe@users.noreply.github.com>
1 parent f786171 commit 6741d8f

2 files changed

Lines changed: 18 additions & 4 deletions

File tree

Calendar/CalLogHelpers/CalLogCSVFunctions.ps1

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -570,12 +570,26 @@ Builds the CSV output from the Calendar Diagnostic Objects
570570
function BuildCSV {
571571

572572
Write-Host "Starting to Process Calendar Logs..."
573-
$script:GCDO = RemoveDuplicateCalendarDiagnosticObjects -CalLogs $script:GCDO
573+
# De-duplicate while preserving the original collection order for RAW output.
574574
$rawNullCount = @($script:GCDO).Count - @($script:GCDO | Where-Object { $null -ne $_ }).Count
575575
if ($rawNullCount -gt 0) {
576576
Write-Host -ForegroundColor Yellow "Removed [$rawNullCount] null raw calendar log row(s) before processing."
577577
}
578-
$script:GCDO = @($script:GCDO | Where-Object { $null -ne $_ })
578+
$dedupedCalLogs = New-Object 'System.Collections.Generic.List[object]'
579+
$seenCalLogKeys = New-Object 'System.Collections.Generic.HashSet[string]'
580+
$duplicateCount = 0
581+
foreach ($calLog in @($script:GCDO | Where-Object { $null -ne $_ })) {
582+
$calLogKey = Get-CalendarDiagnosticObjectDeduplicationKey -CalLog $calLog
583+
if ($seenCalLogKeys.Add($calLogKey)) {
584+
[void]$dedupedCalLogs.Add($calLog)
585+
} else {
586+
$duplicateCount++
587+
}
588+
}
589+
if ($duplicateCount -gt 0) {
590+
Write-Host -ForegroundColor Yellow "Removed [$duplicateCount] duplicate Calendar Log entries before processing."
591+
}
592+
$script:GCDO = @($dedupedCalLogs)
579593
$script:MailboxList = @{}
580594
# Initialize lookup caches to avoid redundant CN resolution across hundreds of log entries
581595
$script:SMTPAddressCache = @{}

Calendar/CalLogHelpers/ExceptionCollectionFunctions.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ function Convert-AppointmentRecurrenceBlobToBytes {
6565
)
6666

6767
if ($AppointmentRecurrenceBlob -is [byte[]]) {
68-
return , $AppointmentRecurrenceBlob
68+
return $AppointmentRecurrenceBlob
6969
}
7070

7171
$blobText = [string]$AppointmentRecurrenceBlob
@@ -83,7 +83,7 @@ function Convert-AppointmentRecurrenceBlobToBytes {
8383
$bytes[$index / 2] = [Convert]::ToByte($blobText.Substring($index, 2), 16)
8484
}
8585

86-
return , $bytes
86+
return $bytes
8787
}
8888

8989
function Get-RecentExceptionCutoff {

0 commit comments

Comments
 (0)