From fc249547264aafd04d23394f27d19c943d1601ff Mon Sep 17 00:00:00 2001 From: fukusuket <41001169+fukusuket@users.noreply.github.com> Date: Fri, 21 Mar 2025 01:11:14 +0900 Subject: [PATCH] chg: Output horizontally --- WELA.ps1 | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/WELA.ps1 b/WELA.ps1 index 376431cb..84a4c998 100644 --- a/WELA.ps1 +++ b/WELA.ps1 @@ -59,23 +59,24 @@ function Set-Applicable { function Get-RuleCounts { param ($rules) $levels = @("critical", "high", "medium", "low", "informational") - $counts = $rules | Group-Object -Property level | ForEach-Object { - [PSCustomObject]@{ - Level = $_.Name - Count = $_.Count - } + $counts = @{} + + $rules | Group-Object -Property level | ForEach-Object { + $counts[$_.Name] = $_.Count } foreach ($level in $levels) { - if (-not ($counts | Where-Object { $_.Level -eq $level })) { - $counts += [PSCustomObject]@{ - Level = $level - Count = 0 - } + if (-not $counts.ContainsKey($level)) { + $counts[$level] = 0 } } - return $counts + return $counts.GetEnumerator() | ForEach-Object { + [PSCustomObject]@{ + Level = $_.Key + Count = $_.Value + } + } } function CalculateUsableRate {