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 <noreply@anthropic.com>
This commit is contained in:
@@ -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'
|
||||
|
||||
Reference in New Issue
Block a user