Skip to content

Commit 72e34ef

Browse files
authored
Enhance tool verification with detailed stats and summary
Added detailed statistics and summary output for tool verification results.
1 parent 472008c commit 72e34ef

1 file changed

Lines changed: 89 additions & 2 deletions

File tree

SystemTester.ps1

Lines changed: 89 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ function Test-ToolIntegrity {
9595

9696
# Verify all tools
9797
function Test-ToolVerification {
98-
# ... (code unchanged)
9998
Write-Host "`n========================================" -ForegroundColor Cyan
10099
Write-Host " TOOL INTEGRITY VERIFICATION" -ForegroundColor Cyan
101100
Write-Host "========================================" -ForegroundColor Cyan
@@ -107,7 +106,95 @@ function Test-ToolVerification {
107106
"testlimit","diskext","listdlls","psping"
108107
)
109108

110-
# ... (rest of verification logic)
109+
$stats = @{
110+
VALID_MS=0; VALID_OTHER=0; NOT_SIGNED=0
111+
BAD_SIZE=0; BAD_SIGNATURE=0; MISSING=0; CHECK_FAILED=0
112+
}
113+
114+
$verificationOutput = @() # Array to hold clean output for the report
115+
$start = Get-Date
116+
117+
foreach ($tool in $allTools) {
118+
$result = Test-ToolIntegrity -ToolName $tool
119+
$stats[$result.Status]++
120+
121+
$color = switch ($result.Status) {
122+
"VALID_MS" { "Green" }
123+
"VALID_OTHER" { "Cyan" }
124+
"NOT_SIGNED" { "Yellow" }
125+
"MISSING" { "Red" }
126+
"BAD_SIZE" { "Red" }
127+
"BAD_SIGNATURE" { "Red" }
128+
"CHECK_FAILED" { "Yellow" }
129+
}
130+
131+
$statusText = switch ($result.Status) {
132+
"VALID_MS" { "[OK-MS]" }
133+
"VALID_OTHER" { "[OK-OTHER]" }
134+
"NOT_SIGNED" { "[NO-SIG]" }
135+
"MISSING" { "[MISSING]" }
136+
"BAD_SIZE" { "[BAD-SIZE]" }
137+
"BAD_SIGNATURE" { "[BAD-SIG]" }
138+
"CHECK_FAILED" { "[ERROR]" }
139+
}
140+
141+
# Display the result (as before)
142+
Write-Host "$statusText $tool" -ForegroundColor $color
143+
144+
# Record the clean output line
145+
$verificationOutput += "$statusText $tool"
146+
147+
if ($result.Details -and $result.Status -ne "VALID_MS") {
148+
Write-Host " $($result.Details)" -ForegroundColor DarkGray
149+
$verificationOutput += " $($result.Details)"
150+
}
151+
}
152+
153+
Write-Host ""
154+
Write-Host "========================================" -ForegroundColor Cyan
155+
Write-Host "SUMMARY:" -ForegroundColor White
156+
157+
# Store the full summary in a dedicated output variable
158+
$summaryOutput = @()
159+
$summaryOutput += "SUMMARY:"
160+
$summaryOutput += " Total Tools: $($allTools.Count)"
161+
$summaryOutput += " Valid (Microsoft): $($stats.VALID_MS)"
162+
$summaryOutput += " Valid (Other): $($stats.VALID_OTHER)"
163+
$summaryOutput += " Not Signed: $($stats.NOT_SIGNED)"
164+
$summaryOutput += " Issues: $($stats.BAD_SIZE + $stats.BAD_SIGNATURE + $stats.MISSING + $stats.CHECK_FAILED)"
165+
166+
# Display the summary stats (as before)
167+
$summaryOutput | ForEach-Object {
168+
if ($_ -match "Total Tools" -or $_ -match "Valid") { Write-Host $_ -ForegroundColor White }
169+
if ($_ -match "Issues") { Write-Host $_ -ForegroundColor Red }
170+
if ($_ -match "Not Signed") { Write-Host $_ -ForegroundColor Yellow }
171+
}
172+
173+
$totalIssues = $stats.BAD_SIZE + $stats.BAD_SIGNATURE + $stats.MISSING + $stats.CHECK_FAILED
174+
$statusLine = if ($totalIssues -eq 0 -and $stats.VALID_MS -gt 0) {
175+
"STATUS: All present tools are verified and safe to use"
176+
} elseif ($totalIssues -gt 0) {
177+
"STATUS: $totalIssues issue(s) detected - recommend re-download"
178+
} else {
179+
"STATUS: Check incomplete or no tools found"
180+
}
181+
182+
Write-Host ""
183+
Write-Host $statusLine -ForegroundColor Green
184+
Write-Host ""
185+
186+
$duration = ((Get-Date) - $start).TotalMilliseconds
187+
188+
# *** NEW CRITICAL BLOCK: Store the results in $script:TestResults ***
189+
$script:TestResults += @{
190+
Tool="Tool-Verification";
191+
Description="Sysinternals Tool Integrity Check";
192+
Status=($statusLine -split ":")[0];
193+
Output=($verificationOutput -join "`n");
194+
Summary=($summaryOutput -join "`n");
195+
Duration=$duration
196+
}
197+
# *******************************************************************
111198
}
112199

113200
# Initialize environment

0 commit comments

Comments
 (0)