top of page

Fix [wsl --help | more] & [wsl --help | Select-String] in PowerShell

Updated: May 19, 2023


The Windows 10 logo with Linux Tux overlay

By default wsl outputs UTF-16LE. This causes issues when piping output to more or Select-String. This post describes a fix. TL;DR Set $env:WSL_UTF8=1


Issue

Typing:

wsl --help | more

...you see:

C
o
r
p
o
r
a
t
i
o
n
.

A
l
l

-- More  --

Fix

Run this to fix:

$env:WSL_UTF8=1

These work now:

wsl --help | more
wsl --help | Select-String "Display"

Revert back with the following:

$env:WSL_UTF8=0 


Environment

systeminfo /fo csv | ConvertFrom-Csv | select OS*, System*, Hotfix* | Format-List -Property 'OS Version'
# OS Version : 10.0.19045 N/A Build 19045
$PSVersionTable
# Name                           Value
# ----                           -----
# PSVersion                      5.1.19041.2673
# PSEdition                      Desktop
# PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
# BuildVersion                   10.0.19041.2673
# CLRVersion                     4.0.30319.42000
# WSManStackVersion              3.0
# PSRemotingProtocolVersion      2.3
# SerializationVersion           1.1.0.1
wsl --version | Select-String "WSL version"
# WSL version: 1.2.5.0


References

wsl.exe outputting unicode to stdout #4607


wsl release with WSL_UTF8=1


about_Character_Encoding


UTF-16


Windows 10 Logo


Tux Logo

Tux (mascot). (2023, April 10). In Wikipedia. https://en.wikipedia.org/wiki/Tux_(mascot)

bottom of page