r/PowerShell • u/Old_Cow_6636 • Jun 11 '26
News What's the least insane way to make registry changes reversible in powershell?
Been working on a little tool that disables brave's bloat (rewards, wallet, vpn, leo, all the telemetry stuff) through the official enterprise policies. the actual policy part was easy. the part that kept me up was not wanting to brick someone's registry.
here's what i ended up doing, tell me if i'm overthinking it:
nothing writes unless you pass -Apply. by default it just prints what it would do
-WhatIf still works even if you pass -Apply, since i hooked into ShouldProcess
before it writes anything it dumps the old values to a timestamped json so there's always a way back the undo (-UndoFromBackup) checks the backup metadata first, and restores are locked to brave's policy keys only so a messed up backup can't write random keys
it straight up refuses to touch anything that'd disable safe browsing or updates, even if you ask
the one thing i keep going back and forth on is the backup format. i went with json snapshots per run. would you have just used reg export / .reg files instead? or Export-Clixml? feels like everyone does this differently and i might be reinventing the wheel.
repo if anyone wants to check it out: https://github.com/osfv/BraveDebloater