From 9bef6d50f50c9a5361bc54df9c36010e110fbd8f Mon Sep 17 00:00:00 2001 From: Tomas Kracmar Date: Wed, 29 Jul 2026 11:54:47 +0200 Subject: [PATCH] fix(Test-WeakADPasswords): prevent report column truncation $testResults | Out-String used the default formatter width, which truncates long columns at the console/default width. The report text is re-parsed line-by-line to attach "UPN:" annotations, taking the first whitespace token as SamAccountName - a truncated account name would silently fail to match $dictionarySamToUpn and drop the annotation with no error. Pass -Width 4096 to avoid truncation. Co-Authored-By: Claude Sonnet 5 --- Test-WeakADPasswords.ps1 | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Test-WeakADPasswords.ps1 b/Test-WeakADPasswords.ps1 index 6768fb8..0838c10 100644 --- a/Test-WeakADPasswords.ps1 +++ b/Test-WeakADPasswords.ps1 @@ -725,7 +725,10 @@ function Test-WeakADPasswords { } Write-Verbose "Generating report at $reportPath" - $reportContent = @($header, ($testResults | Out-String).Trim(), $footer) -join "`r`n" + # -Width prevents PowerShell's default table formatter from truncating long columns (e.g. a + # long SamAccountName) at console/default width, which would otherwise silently break the + # first-token re-parse below used to attach "UPN:" lines to dictionary hits. + $reportContent = @($header, ($testResults | Out-String -Width 4096).Trim(), $footer) -join "`r`n" $lines = $reportContent -split "`r`n" $newReportContent = @()