feat: add automated environment report export (#5025)

* feat: add automated environment report export

* refactor: address code review comments

* fix: refresh toggle state in environment report

* fix: surface environment report read failures

* test: make registry failure explicit

---------

Co-authored-by: Chris Titus <contact@christitus.com>
This commit is contained in:
Omar
2026-09-02 17:03:22 -05:00
committed by GitHub
co-authored by Chris Titus
parent 4a1db91e3f
commit 7ee5be3d2f
12 changed files with 704 additions and 15 deletions
@@ -0,0 +1,39 @@
function Get-WinUtilRecentLogs {
<#
.SYNOPSIS
Concatenates WinUtil session logs from the last N days into a single text blob.
.PARAMETER Days
How many days back to include. Defaults to 7, matching what the support forum/server
typically asks users for.
.PARAMETER LogDirectory
Overrides the log directory (normally $sync.winutildir\logs). Mainly for testing.
#>
param(
[int]$Days = 7,
[string]$LogDirectory
)
if ([string]::IsNullOrWhiteSpace($LogDirectory)) {
if ($null -eq $sync -or -not $sync.ContainsKey("winutildir") -or [string]::IsNullOrWhiteSpace($sync.winutildir)) {
return ""
}
$LogDirectory = Join-Path $sync.winutildir "logs"
}
if (-not (Test-Path $LogDirectory)) {
return ""
}
$cutoff = (Get-Date).AddDays(-$Days)
$logFiles = Get-ChildItem -Path $LogDirectory -Filter "winutil_*.log" -File -ErrorAction SilentlyContinue |
Where-Object { $_.LastWriteTime -ge $cutoff } |
Sort-Object LastWriteTime
$sections = foreach ($logFile in $logFiles) {
"=== $($logFile.Name) ===`n$(Get-Content -Path $logFile.FullName -Raw)"
}
return ($sections -join "`n`n")
}