Tags: SysAdminDoc/DefenderControl
Tags
fix: auto-relaunch under Windows PowerShell 5.1 when invoked from pwsh
Running the script from PowerShell 7 (pwsh.exe) previously errored out with
a MessageBox "Wrong PowerShell Edition" and exited. The script now detects
PSEdition == 'Core' before any WPF load and re-spawns itself under
powershell.exe (Windows PowerShell 5.1) with the full arg list preserved:
CLI mode: Start-Process -Wait -NoNewWindow -PassThru so stdout/stderr/exit
code return to the caller. If not elevated, adds -Verb RunAs so
the single re-launch handles both edition swap and UAC in one
prompt.
GUI mode: Fire-and-forget new window (adds -Verb RunAs if not admin).
If auto-launch fails (unlikely) the CLI path writes a clear error to stderr
and the GUI path surfaces a MessageBox with the manual command.
Arg forwarding factored out into Get-ForwardedArgString so both the edition
re-host and the self-elevation code path use identical logic.
Release v3.2.1.