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 <noreply@anthropic.com>
This commit is contained in:
@@ -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 = @()
|
||||
|
||||
Reference in New Issue
Block a user