Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $makeInstall = "C:\UbuntuWSL\ubuntu1604.exe install --root"
- $mustBeRoot = "C:\UbuntuWSL\ubuntu1604.exe config --default-user root"
- $runShellScript = "C:\UbuntuWSL\ubuntu1604.exe run `"/mnt/c/UbuntuWSL/configureWsl.sh`""
- $setDefaultUser = "C:\UbuntuWSL\ubuntu1604.exe config --default-user $env:USERNAME"
- $Source = "\\nas.dbs.fr\windows\Scripts\WSL\configureWsl.sh"
- if (-not (Test-Path C:\Windows\System32\bash.exe))
- {
- $ProgPref = $ProgressPreference
- $ProgressPreference = 'SilentlyContinue'
- $results = Enable-WindowsOptionalFeature -FeatureName Microsoft-Windows-Subsystem-Linux -Online -NoRestart -WarningAction SilentlyContinue
- $ProgressPreference = $ProgPref
- if ($results.RestartNeeded -eq $true)
- {
- Restart-Computer -Force
- }
- }
- else
- {
- if ( -not (Test-Path -Path 'C:\UbuntuWSL' -PathType Container) )# -not
- {
- Invoke-WebRequest -Uri https://aka.ms/wsl-ubuntu-1604 -OutFile C:\Temp\ubuntu.zip -UseBasicParsing
- Expand-Archive C:\Temp\ubuntu.zip C:\UbuntuWSL -Force
- Invoke-Expression -Command:$makeInstall
- Copy-Item $Source -Destination C:\UbuntuWSL
- Invoke-Expression -Command:$mustBeRoot
- Invoke-Expression -Command:$runShellScript
- Invoke-Expression -Command:$setDefaultUser
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement