PowerShell/docs/list-wsl-distros.md

69 lines
1.6 KiB
Markdown
Raw Normal View History

2024-01-25 13:37:12 +01:00
Script: *list-wsl-distros.ps1*
========================
2023-10-19 08:12:00 +02:00
2024-11-08 12:35:11 +01:00
This PowerShell script lists installed/available Linux distributions for Windows Subsystem for Linux (WSL).
2023-10-19 08:12:00 +02:00
Parameters
----------
```powershell
2024-11-08 12:35:11 +01:00
/home/markus/Repos/PowerShell/scripts/list-wsl-distros.ps1 [<CommonParameters>]
2023-10-19 08:12:00 +02:00
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,
WarningVariable, OutBuffer, PipelineVariable, and OutVariable.
```
2024-11-08 12:35:11 +01:00
Example
-------
```powershell
PS> ./list-wsl-distros.ps1
NAME STATE VERSION
* Ubuntu-24.04 Stopped 2
...
```
Notes
-----
Author: Markus Fleschutz | License: CC0
Related Links
-------------
https://github.com/fleschutz/PowerShell
2023-10-19 08:12:00 +02:00
Script Content
--------------
```powershell
2024-11-08 12:35:11 +01:00
<#
.SYNOPSIS
Lists distros for Windows Subsystem for Linux
.DESCRIPTION
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
Author: Markus Fleschutz | License: CC0
#>
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: $($Error[0]) in script line $($_.InvocationInfo.ScriptLineNumber)."
exit 1
}
2023-10-19 08:12:00 +02:00
```
2024-11-08 12:35:11 +01:00
*(generated by convert-ps2md.ps1 using the comment-based help of list-wsl-distros.ps1 as of 11/08/2024 12:34:52)*