Browse Source

improved WSL-Install function

pull/455/head
Dmitry Nefedov 2 years ago
parent
commit
de13af6d9c
  1. 10
      src/Sophia_Script_for_Windows_10/Module/Sophia.psm1
  2. 10
      src/Sophia_Script_for_Windows_10_LTSC_2021/Module/Sophia.psm1
  3. 10
      src/Sophia_Script_for_Windows_10_PowerShell_7/Module/Sophia.psm1
  4. 6
      src/Sophia_Script_for_Windows_11/Module/Sophia.psm1
  5. 6
      src/Sophia_Script_for_Windows_11_PowerShell_7/Module/Sophia.psm1

10
src/Sophia_Script_for_Windows_10/Module/Sophia.psm1

@ -9681,10 +9681,14 @@ function Install-WSL
{
[System.Console]::OutputEncoding = [System.Text.Encoding]::Unicode
$Distros = (wsl --list --online | Select-Object -Skip 4).Replace(" ", "").Replace("* ", "") | ForEach-Object -Process {
$wsl = wsl --list --online
# We need to get the string number where the "FRIENDLY NAME" header begins to truncate all other unnecessary strings in the beginning
$LineNumber = ($wsl | Select-String -Pattern "FRIENDLY NAME" -CaseSensitive).LineNumber
# Remove first strings in output from the first to the $LineNumber
$Distros = ($wsl).Replace("* ", "")[($LineNumber)..(($wsl).Count)] | ForEach-Object -Process {
[PSCustomObject]@{
"Distro" = $_ -split " ", 2 | Select-Object -Last 1
"Alias" = $_ -split " ", 2 | Select-Object -First 1
"Distro" = ($_ -split " ", 2 | Select-Object -Last 1).Trim()
"Alias" = ($_ -split " ", 2 | Select-Object -First 1).Trim()
}
}

10
src/Sophia_Script_for_Windows_10_LTSC_2021/Module/Sophia.psm1

@ -8649,10 +8649,14 @@ function Install-WSL
{
[System.Console]::OutputEncoding = [System.Text.Encoding]::Unicode
$Distros = (wsl --list --online | Select-Object -Skip 4).Replace(" ", "").Replace("* ", "") | ForEach-Object -Process {
$wsl = wsl --list --online
# We need to get the string number where the "FRIENDLY NAME" header begins to truncate all other unnecessary strings in the beginning
$LineNumber = ($wsl | Select-String -Pattern "FRIENDLY NAME" -CaseSensitive).LineNumber
# Remove first strings in output from the first to the $LineNumber
$Distros = ($wsl).Replace("* ", "")[($LineNumber)..(($wsl).Count)] | ForEach-Object -Process {
[PSCustomObject]@{
"Distro" = $_ -split " ", 2 | Select-Object -Last 1
"Alias" = $_ -split " ", 2 | Select-Object -First 1
"Distro" = ($_ -split " ", 2 | Select-Object -Last 1).Trim()
"Alias" = ($_ -split " ", 2 | Select-Object -First 1).Trim()
}
}

10
src/Sophia_Script_for_Windows_10_PowerShell_7/Module/Sophia.psm1

@ -9684,10 +9684,14 @@ function Install-WSL
{
[System.Console]::OutputEncoding = [System.Text.Encoding]::Unicode
$Distros = (wsl --list --online | Select-Object -Skip 4).Replace(" ", "").Replace("* ", "") | ForEach-Object -Process {
$wsl = wsl --list --online
# We need to get the string number where the "FRIENDLY NAME" header begins to truncate all other unnecessary strings in the beginning
$LineNumber = ($wsl | Select-String -Pattern "FRIENDLY NAME" -CaseSensitive).LineNumber
# Remove first strings in output from the first to the $LineNumber
$Distros = ($wsl).Replace("* ", "")[($LineNumber)..(($wsl).Count)] | ForEach-Object -Process {
[PSCustomObject]@{
"Distro" = $_ -split " ", 2 | Select-Object -Last 1
"Alias" = $_ -split " ", 2 | Select-Object -First 1
"Distro" = ($_ -split " ", 2 | Select-Object -Last 1).Trim()
"Alias" = ($_ -split " ", 2 | Select-Object -First 1).Trim()
}
}

6
src/Sophia_Script_for_Windows_11/Module/Sophia.psm1

@ -9346,10 +9346,10 @@ function Install-WSL
# We need to get the string number where the "FRIENDLY NAME" header begins to truncate all other unnecessary strings in the beginning
$LineNumber = ($wsl | Select-String -Pattern "FRIENDLY NAME" -CaseSensitive).LineNumber
# Remove first strings in output from the first to the $LineNumber
$Distros = ($wsl).Replace(" ", "").Replace("* ", "")[($LineNumber)..(($wsl).Count)] | ForEach-Object -Process {
$Distros = ($wsl).Replace("* ", "")[($LineNumber)..(($wsl).Count)] | ForEach-Object -Process {
[PSCustomObject]@{
"Distro" = $_ -split " ", 2 | Select-Object -Last 1
"Alias" = $_ -split " ", 2 | Select-Object -First 1
"Distro" = ($_ -split " ", 2 | Select-Object -Last 1).Trim()
"Alias" = ($_ -split " ", 2 | Select-Object -First 1).Trim()
}
}

6
src/Sophia_Script_for_Windows_11_PowerShell_7/Module/Sophia.psm1

@ -9349,10 +9349,10 @@ function Install-WSL
# We need to get the string number where the "FRIENDLY NAME" header begins to truncate all other unnecessary strings in the beginning
$LineNumber = ($wsl | Select-String -Pattern "FRIENDLY NAME" -CaseSensitive).LineNumber
# Remove first strings in output from the first to the $LineNumber
$Distros = ($wsl).Replace(" ", "").Replace("* ", "")[($LineNumber)..(($wsl).Count)] | ForEach-Object -Process {
$Distros = ($wsl).Replace("* ", "")[($LineNumber)..(($wsl).Count)] | ForEach-Object -Process {
[PSCustomObject]@{
"Distro" = $_ -split " ", 2 | Select-Object -Last 1
"Alias" = $_ -split " ", 2 | Select-Object -First 1
"Distro" = ($_ -split " ", 2 | Select-Object -Last 1).Trim()
"Alias" = ($_ -split " ", 2 | Select-Object -First 1).Trim()
}
}

Loading…
Cancel
Save