Updated list-wsl-distros.ps1

This commit is contained in:
Markus Fleschutz 2024-09-10 16:23:05 +02:00
parent ad73e693cb
commit b8d9a4dc19

View File

@ -2,9 +2,12 @@
.SYNOPSIS
Lists distros for Windows Subsystem for Linux
.DESCRIPTION
This PowerShell script lists available Linux distributions for Windows Subsystem for Linux (WSL).
This PowerShell script lists installed/available Linux distributions for Windows Subsystem for Linux (WSL).
.EXAMPLE
PS> ./list-wsl-distros.ps1
NAME STATE VERSION
* Ubuntu-24.04 Stopped 2
...
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
@ -12,11 +15,15 @@
#>
try {
if ($IsLinux -or $IsMacOS) { throw "Requires Windows Subsystem for Linux (WSL)" }
& wsl.exe --list --verbose
" "
& wsl.exe --list --online
" "
& wsl.exe --status
exit 0 # success
} catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
"⚠️ Error: $($Error[0]) in script line $($_.InvocationInfo.ScriptLineNumber)."
exit 1
}