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
@@ -11,7 +11,9 @@ Function Invoke-WinUtilCurrentSystem {
#>
param(
$CheckBox
$CheckBox,
[switch]$BypassToggleStatusCache,
[switch]$StopOnReadError
)
if ($CheckBox -eq "choco") {
$apps = (choco list | Select-String -Pattern "^\S+").Matches.Value
@@ -52,6 +54,7 @@ Function Invoke-WinUtilCurrentSystem {
if ($CheckBox -eq "tweaks") {
if (!(Test-Path 'HKU:\')) {$null = (New-PSDrive -PSProvider Registry -Name HKU -Root HKEY_USERS)}
$readErrorAction = if ($StopOnReadError) { "Stop" } else { "SilentlyContinue" }
$sync.configs.tweaks | Get-Member -MemberType NoteProperty | ForEach-Object {
@@ -65,7 +68,9 @@ Function Invoke-WinUtilCurrentSystem {
$Values = @()
if ($entryType -eq "Toggle") {
if (-not (Get-WinUtilToggleStatus $Config)) {
if (-not (Get-WinUtilToggleStatus $Config `
-BypassCache:$BypassToggleStatusCache `
-StopOnReadError:$StopOnReadError)) {
$values += $False
}
} else {
@@ -77,8 +82,12 @@ Function Invoke-WinUtilCurrentSystem {
$registryTotal++
$regstate = $null
if (Test-Path $tweak.Path) {
$regstate = Get-ItemProperty -Name $tweak.Name -Path $tweak.Path -ErrorAction SilentlyContinue | Select-Object -ExpandProperty $($tweak.Name)
if (Test-Path $tweak.Path -ErrorAction $readErrorAction) {
if ($StopOnReadError) {
$regstate = (Get-ItemProperty -Path $tweak.Path -ErrorAction Stop).$($tweak.Name)
} else {
$regstate = Get-ItemProperty -Name $tweak.Name -Path $tweak.Path -ErrorAction SilentlyContinue | Select-Object -ExpandProperty $($tweak.Name)
}
}
if ($null -eq $regstate) {