diff --git a/CHANGELOG.md b/CHANGELOG.md index f6a060e..e41a833 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ Starting with **v2.2.0**, Elysium uses a **unified project version**. All script - `decrypt.py` could not decrypt any current export: it did not recognize `ELY2` (so v2.4.6 files fell through to the legacy branch), and its `ELY1` branch used pycryptodome's default PBKDF2 PRF (HMAC-SHA1) while `Extract-NTHashes.ps1` has always used HMAC-SHA256. It now reads `ELY2` (verifying the HMAC before decrypting), `ELY1`, and the legacy format; encodes the passphrase as UTF-8 to match .NET; prompts for the passphrase without echo; refuses input that does not end in `.enc` instead of overwriting it; and exits non-zero on failure. New `tests/test_decrypt.py` round-trips through the real PowerShell encryptor. - `Test-WeakADPasswords.ps1` did not relaunch under Windows PowerShell like `Extract-NTHashes.ps1` does, so a direct run under `pwsh` loaded DSInternals through `-UseWindowsPowerShell` implicit remoting, which returns deserialized objects. It also set the PSGallery repository to `Trusted` on the host as a side effect of installing DSInternals; that is removed (`-Force` on the install already covers the prompt). - `Update-LithnetStore.ps1` ignored `InstallationPath`/`WeakPasswordsDatabase` and always looked for `khdb.txt` next to the script; it now resolves the same KHDB path as the other scripts. It also writes a transcript to `Reports/logs/` like the other operational scripts and uses the shared settings parser instead of its own copy. +- The `Restart-WithPwshIfAvailable` / `Restart-WithWindowsPowerShellIfAvailable` relaunchers in `Elysium.Common.ps1` relaunched `Elysium.Common.ps1` itself instead of the calling script (`$PSCommandPath` inside a function is the file that defines it), then exited. Whenever a relaunch fired, the script silently did nothing: `Update-KHDB.ps1`, `Prepare-KHDBStorage.ps1`, `Update-LithnetStore.ps1` and `Uninstall.ps1` started from Windows PowerShell on a host with `pwsh` installed (including menu options 1, 4 and 5), and `Extract-NTHashes.ps1` / `Test-WeakADPasswords.ps1` started directly from `pwsh`. They now relaunch the calling script with its parameters. ## [2.4.6] — 2026-07-29 diff --git a/Elysium.Common.ps1 b/Elysium.Common.ps1 index 467208e..da2002c 100644 --- a/Elysium.Common.ps1 +++ b/Elysium.Common.ps1 @@ -3,14 +3,15 @@ $script:ElysiumVersion = '2.4.6' function Invoke-RestartWithExecutable { param( [string]$ExecutablePath, + [string]$ScriptPath, [hashtable]$BoundParameters, [object[]]$UnboundArguments ) if (-not $ExecutablePath) { return } - if (-not $PSCommandPath) { return } + if (-not $ScriptPath) { return } - $argList = @('-NoLogo', '-NoProfile', '-File', $PSCommandPath) + $argList = @('-NoLogo', '-NoProfile', '-File', $ScriptPath) if ($BoundParameters) { foreach ($entry in $BoundParameters.GetEnumerator()) { @@ -43,7 +44,9 @@ function Restart-WithPwshIfAvailable { $pwsh = Get-Command -Name 'pwsh' -ErrorAction SilentlyContinue if (-not $pwsh) { return } Write-Host ("PowerShell 7 detected at '{0}'; relaunching script under pwsh..." -f $pwsh.Path) - Invoke-RestartWithExecutable -ExecutablePath $pwsh.Path -BoundParameters $BoundParameters -UnboundArguments $UnboundArguments + # $PSCommandPath here would be this helper file (where the function is defined), not the + # script being relaunched; $MyInvocation.PSCommandPath is the script that called us. + Invoke-RestartWithExecutable -ExecutablePath $pwsh.Path -ScriptPath $MyInvocation.PSCommandPath -BoundParameters $BoundParameters -UnboundArguments $UnboundArguments } function Restart-WithWindowsPowerShellIfAvailable { @@ -68,7 +71,7 @@ function Restart-WithWindowsPowerShellIfAvailable { return } Write-Host ("Windows PowerShell detected at '{0}'; relaunching script under powershell.exe..." -f $powershellPath) - Invoke-RestartWithExecutable -ExecutablePath $powershellPath -BoundParameters $BoundParameters -UnboundArguments $UnboundArguments + Invoke-RestartWithExecutable -ExecutablePath $powershellPath -ScriptPath $MyInvocation.PSCommandPath -BoundParameters $BoundParameters -UnboundArguments $UnboundArguments } # ---------------------------------------------------------------------------