From 80199ad7d672735d1cfb1e972380d6e07e55c360 Mon Sep 17 00:00:00 2001 From: Tomas Kracmar Date: Wed, 29 Jul 2026 12:06:12 +0200 Subject: [PATCH] fix(Extract-NTHashes): pin plaintext hash export to UTF-8 Out-File defaults to UTF-16LE on Windows PowerShell 5.1 (Desktop) and UTF-8 on PowerShell 7 (Core), so the encoding of the transient plaintext hash export depended purely on which host happened to run the script - inconsistent with Test-WeakADPasswords.ps1/ Update-KHDB.ps1, which already pin this. Applied the same $PSDefaultParameterValues['Out-File:Encoding'] = 'utf8' pattern. Co-Authored-By: Claude Sonnet 5 --- Extract-NTHashes.ps1 | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Extract-NTHashes.ps1 b/Extract-NTHashes.ps1 index 333a3b9..e51870d 100644 --- a/Extract-NTHashes.ps1 +++ b/Extract-NTHashes.ps1 @@ -23,6 +23,14 @@ This script will connect to selected domain (defined in ElysiumSettings.txt) usi $ErrorActionPreference = 'Stop' Set-StrictMode -Version Latest +# Ensure consistent UTF-8 output for files across PS5.1/PS7 (Out-File defaults to UTF-16LE on +# Desktop edition and UTF-8 on Core, so the plaintext hash export's encoding would otherwise +# depend purely on which PowerShell host happens to run it). +try { + $PSDefaultParameterValues['Out-File:Encoding'] = 'utf8' + $OutputEncoding = New-Object System.Text.UTF8Encoding($false) +} catch { } + $scriptRoot = $PSScriptRoot [string]$commonHelper = Join-Path -Path $PSScriptRoot -ChildPath 'Elysium.Common.ps1'