Add optimization & troubleshooting engines + interactive menu#1
Conversation
Optimize-Windows-Senior.ps1: a second registry-driven engine that changes Windows settings instead of deleting files. 29 declarative tweaks across Performance, Privacy, Debloat and Network. Each apply is snapshotted into a backup manifest first, so -Undo reverts a whole run; a restore point is made too. Types: Registry, Service, ScheduledTask and Custom (Appx/power/Nagle). Debatable tweaks ship off by default. Never touches Defender real-time protection, Windows Update, the network stack wholesale, or Edge/Store. WinSenior.ps1: one self-elevating menu that drives both engines. Detailed cleanup and optimization screens (toggle, preview, run), undo, restore point and listings. Runs engines as child calls; reproduces a toggled selection via -Include/-Exclude. Tests: Pester 5 for tweak-registry integrity, selection, and a registry backup->apply->undo round-trip. CI now parse-checks and analyzes all three scripts. Docs + design spec updated. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Repair-Windows-Senior.ps1: a third registry-driven engine that diagnoses and repairs system health. 13 checks across Integrity, Disk, Update, Network, Devices, Services, Security and System. Each check is a read-only Scan (OK/Warn/Fail) plus an optional Fix. Flow is scan-then-choose: scan changes nothing, prints a health report, then lets you pick which issues to repair via ShouldProcess after a restore point. Heavy repairs (SFC, DISM RestoreHealth, Windows Update reset, network stack reset, reboot) only run when selected or with -FixAll -IncludeHeavy. Image health uses Repair-WindowsImage CheckHealth (locale-independent) rather than parsing DISM text. Repairs only improve health - the engine enables Defender, never disables it. WinSenior.ps1: new Troubleshoot tab driving the engine (scan & repair, scan only, auto-fix safe, auto-fix all). Tests: Pester 5 for check-registry integrity, selection, and scan/fix dispatch with synthetic checks. CI parse-checks and analyzes all four scripts. Docs updated. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Hold the connectivity-test address in a variable so PSAvoidUsingComputerNameHardcoded no longer fires on the network health check. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 54ef4e2ff9
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (Test-Path $p) { Rename-Item $p "$p.old_$(Get-Date -Format 'yyyyMMddHHmmss')" -Force -ErrorAction SilentlyContinue } | ||
| } | ||
| foreach ($s in 'cryptsvc','bits','wuauserv') { Start-Service $s -ErrorAction SilentlyContinue } | ||
| } -FixRisk Moderate -FixLabel 'Reset Windows Update (rename SoftwareDistribution/catroot2)' |
There was a problem hiding this comment.
Keep Windows Update reset out of default FixAll
When wu-health reports a large cache or disabled wuauserv, -FixAll selects every fix with FixRisk <= Moderate, so this Windows Update reset runs without -IncludeHeavy. That contradicts the script's documented flow that Windows Update reset is a heavy repair requiring explicit selection or -FixAll -IncludeHeavy, and it can unnecessarily stop update services and rename SoftwareDistribution/catroot2 during unattended safe repairs.
Useful? React with 👍 / 👎.
| $dirty = @() | ||
| foreach ($d in (Get-CimInstance Win32_LogicalDisk -Filter 'DriveType=3' -ErrorAction SilentlyContinue)) { | ||
| & fsutil.exe dirty query "$($d.DeviceID)" *>$null | ||
| if ($LASTEXITCODE -eq 0) { $dirty += $d.DeviceID } |
There was a problem hiding this comment.
Parse fsutil output before marking volumes dirty
On a normal clean volume, fsutil dirty query still succeeds; the dirty state is in the output text (is dirty vs is not dirty, per Microsoft's fsutil documentation), not the success exit code. As written, default scans can report every successfully queried fixed disk as dirty, and -FixAll then runs chkdsk /scan unnecessarily on all of them.
Useful? React with 👍 / 👎.
| $script:Results.Add((Invoke-Scan -Check $c)) | ||
| } | ||
| Show-ScanReport | ||
| Write-RepReport |
There was a problem hiding this comment.
Write repair reports after fixes complete
With -ReportPath and any repair mode such as -FixAll, this writes the JSON report immediately after the scan, before Invoke-Fix updates Fixed, FixErrors, or RebootNeeded, and there is no second report write after the repair loop. Automation consuming the report will therefore see Fixed: 0 and Reboot: false even when repairs were performed.
Useful? React with 👍 / 👎.
| -Explain 'Creates and activates the hidden Ultimate Performance plan (desktops/workstations).' ` | ||
| -Test { $false } ` | ||
| -Backup { $a = (& powercfg /getactivescheme) -join ' '; $g = if ($a -match '([0-9a-f-]{36})') { $Matches[1] } else { $null }; @{ PreviousGuid = $g } } ` | ||
| -Apply { & powercfg /duplicatescheme e9a42b02-d5df-448d-aa00-03f14749eb61 2>$null; & powercfg /setactive e9a42b02-d5df-448d-aa00-03f14749eb61 2>$null } ` |
There was a problem hiding this comment.
Activate the duplicated Ultimate plan GUID
When perf-power-ultimate is included, powercfg /duplicatescheme without a destination creates a new scheme GUID, but this command ignores that output and tries to activate the original template GUID. On systems where the template is not already an installed scheme, the new Ultimate Performance plan is left inactive while the tweak is still recorded as applied; capture the generated GUID or pass a destination GUID and activate that.
Useful? React with 👍 / 👎.
Overview
Turns the cleaner into a full maintenance suite with a single entry point. Adds two new
registry-driven engines (optimization and troubleshooting) alongside the existing cleanup
engine, plus an interactive menu (
WinSenior.ps1) that ties all three together. Same provenarchitecture: declarative registries, real
-WhatIfviaSupportsShouldProcess, risk tiers,JSON reports, standalone-runnable for automation.
Optimization engine (
Optimize-Windows-Senior.ps1)Changes Windows settings instead of deleting files. 29 tweaks across Performance, Privacy,
Debloat and Network. Each apply is snapshotted into a JSON backup manifest first, so
-Undoreverts a whole run; a restore point is created too. Types: Registry, Service, ScheduledTask
and Custom (Appx / power scheme / hibernation / Nagle). Debatable tweaks ship off by default.
Never disables Defender real-time protection, never breaks Windows Update or the network stack
wholesale, never removes Edge/Store.
Troubleshooting engine (
Repair-Windows-Senior.ps1)Diagnoses and repairs system health. 13 checks across Integrity, Disk, Update, Network,
Devices, Services, Security and System. Each check is a read-only scan (OK / Warn / Fail) plus
an optional fix. Flow is scan → report → choose: it scans (changing nothing), prints a
health report, then repairs the issues you select, through
ShouldProcessafter a restorepoint. Heavy repairs (SFC, DISM RestoreHealth, Windows Update reset, network stack reset) only
run when selected, or with
-FixAll -IncludeHeavy. Repairs only improve health — the engineenables Defender, it never disables it.
Menu (
WinSenior.ps1)Self-elevating single entry point. Detailed screens for cleanup, optimization and
troubleshooting (toggle / preview / run), plus undo, restore point and a task/tweak/check
listing. Runs each engine as a child call; reproduces a toggled selection via
-Include/-Exclude.Tests & CI
Pester 5 tests for tweak-registry integrity, selection, a registry backup -> apply -> undo
round-trip against a throwaway hive, and the troubleshooter's scan/fix dispatch with synthetic
checks. CI now parse-checks and runs PSScriptAnalyzer on all four scripts, and globs all tests.
Green on
windows-latest.Commits
🤖 Generated with Claude Code