fix: Export-RdpRepairDiagnosticReport ломался на одном cert (foreach PS 5.1)

foreach по PSCustomObject перечисляет свойства, не cert — нужен @().
Рекурсивное flatten в Get-RdpRepairCertificateArray, самотест Export-паттерна.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
PTah
2026-06-12 20:32:38 +10:00
parent 5761710fa1
commit d25fea82b1
2 changed files with 26 additions and 6 deletions
+16
View File
@@ -100,6 +100,22 @@ Assert-Test 'Get-RdpRepairCertificateArray flattens nested Object[]' {
if ($first.Thumbprint -ne 'NESTED01') { throw "expected NESTED01 got $($first.Thumbprint)" }
}
Assert-Test 'foreach must use @() wrapper on single cert (Export pattern)' {
$mock = [PSCustomObject]@{
Thumbprint = 'LOOP01'
Subject = 'CN=loop'
NotAfter = (Get-Date).AddDays(1)
HasKey = $true
}
$lines = @()
foreach ($c in @(Get-RdpRepairCertificateArray @($mock))) {
$lines += $c.Subject
}
if ($lines.Count -ne 1 -or $lines[0] -ne 'CN=loop') {
throw "expected CN=loop got $($lines -join ',')"
}
}
Assert-Test 'Get-RdpRepairDiagnosticSnapshot object shape' {
if (-not (Test-RdpRepairIsAdministrator)) {
Write-Host ' (skip snapshot fields - not admin)' -ForegroundColor DarkYellow