mirror of
https://github.com/ChrisTitusTech/winutil.git
synced 2026-10-09 21:21:18 +11:00
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:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user