2024-10-01 15:11:03 +02:00
|
|
|
|
<#
|
2024-09-10 16:03:05 +02:00
|
|
|
|
.SYNOPSIS
|
|
|
|
|
Lists distros for Windows Subsystem for Linux
|
|
|
|
|
.DESCRIPTION
|
2024-09-10 16:23:05 +02:00
|
|
|
|
This PowerShell script lists installed/available Linux distributions for Windows Subsystem for Linux (WSL).
|
2024-09-10 16:03:05 +02:00
|
|
|
|
.EXAMPLE
|
|
|
|
|
PS> ./list-wsl-distros.ps1
|
2024-09-10 16:23:05 +02:00
|
|
|
|
NAME STATE VERSION
|
|
|
|
|
* Ubuntu-24.04 Stopped 2
|
|
|
|
|
...
|
2024-09-10 16:03:05 +02:00
|
|
|
|
.LINK
|
|
|
|
|
https://github.com/fleschutz/PowerShell
|
|
|
|
|
.NOTES
|
|
|
|
|
Author: Markus Fleschutz | License: CC0
|
|
|
|
|
#>
|
|
|
|
|
|
|
|
|
|
try {
|
2024-09-10 16:23:05 +02:00
|
|
|
|
if ($IsLinux -or $IsMacOS) { throw "Requires Windows Subsystem for Linux (WSL)" }
|
|
|
|
|
|
|
|
|
|
& wsl.exe --list --verbose
|
|
|
|
|
" "
|
2024-09-10 16:03:05 +02:00
|
|
|
|
& wsl.exe --list --online
|
|
|
|
|
" "
|
|
|
|
|
& wsl.exe --status
|
|
|
|
|
exit 0 # success
|
|
|
|
|
} catch {
|
2024-09-10 16:23:05 +02:00
|
|
|
|
"⚠️ Error: $($Error[0]) in script line $($_.InvocationInfo.ScriptLineNumber)."
|
2024-09-10 16:03:05 +02:00
|
|
|
|
exit 1
|
|
|
|
|
}
|