Michael Klement
Michael Klement
Pwsh corrupts PATH environment variable, breaking nested invocations on everything that isn't x86-64
That's a good find, @rdebath - I didn't know the backstory. Let me try a **summary** of sorts: * The current behavior of prepending PowerShell's own installation directory to the...
Pwsh corrupts PATH environment variable, breaking nested invocations on everything that isn't x86-64
> I note that there are two executables, `$PSHOME/pwsh.exe` and `$PSHOME/pwsh` for windows and unix which may change things. It matters if a symlink / hardlink solution is pursued, but...
Note that a (process) exit code does _not_ apply to PowerShell-native commands, so you should never expect `$LASTEXITCODE` to be set by them (with the exception of `*.ps1` scripts that...
Great sleuthing, @jborean93. However, note that `[System.Globalization.CultureInfo]::CurrentCulture.TextInfo.ANSICodePage` isn't a robust way to determine the _system's_ active ANSI code page (based on the _system locale_ aka _language for non-Unicode programs_). One...
I just remembered that in PowerShell v7.4+ `Ansi` is now supported as a predefined encoding name: ```powershell Get-Content test.txt -Tail 2 -Encoding Ansi ```
To clarify further: To refer in the _abstract_ to whatever ANSI and OEM code page is implied by a given machine's system locale (aka language for non-Unicode programs), use `-Encoding...
Thanks for sharing this solution; the following is a simpler alternative for transcoding an OEM-encoded file to UTF-8 with BOM: ```powershell Set-Content outputfile.txt -Encoding ('utf8', 'utf8BOM')[[int] $IsCoreClr] -NoNewLine ( Get-Content...
You can adapt the previous command to use a specific OEM code page as follows: ```powershell Set-Content outputfile.txt -Encoding ('utf8', 'utf8BOM')[[int] $IsCoreClr] -NoNewLine ( [IO.File]::ReadAllText((Convert-Path inputfile.txt), [Text.Encoding]::GetEncoding(850)) ) ``` The...
It's definitely surprising and unhelpful behavior that has been in place since v3 (in v2 you get a "Missing property name after reference operator." error). Just to provide some background:...
Thanks for the clarification, @SeeminglyScience; indeed, the problem also happens in regular parameter binding, not just when calling native executables. Given that a native executable happened to be the messenger,...