While your specific use-case can be handled by wsl --list --running
(as mentioned by @X--FARZA_D--X's answer), there are two reasons why your filter wasn't working:
First, you probably were looking for Select-String Running
. PowerShell's Select-Object
would require a PowerShell object with a NAME
property. All wsl.exe
provides is a string output.
But more importantly, it still won't work even after the proper:
wsl -l -v | Select-String Running
This is due to a bug in wsl.exe
that causes it output as a mangled UTF-16. See this and this answer for details.
Given your use-case, you should be able to properly filter with:
$console = ([console]::OutputEncoding)
[console]::OutputEncoding = New-Object System.Text.UnicodeEncoding
wsl -l -v | Select-String Running
[console]::OutputEncoding = $console
Alternatively, if you are using a recent release of WSL (0.64.0 or later) on Windows 11, you could simply:
$env:WSL_UTF8=1
wsl -l -v | Select-String Running