This repository has been archived by the owner on Apr 6, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bootstrap.ps1
98 lines (81 loc) · 3.37 KB
/
bootstrap.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# Run script as admin
if (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) { Start-Process powershell.exe "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`"" -Verb RunAs; exit }
function Write-Header($header)
{
Write-Host "------------------------------------" -ForegroundColor Green
Write-Host $header -ForegroundColor Green
Write-Host "------------------------------------" -ForegroundColor Green
}
function Check-Command($cmdname)
{
return [bool](Get-Command -Name $cmdname -ErrorAction SilentlyContinue)
}
Write-Header "Disable Sleep on AC Power..."
Powercfg /Change standby-timeout-ac 0
# To list all appx packages:
# Get-AppxPackage | Format-Table -Property Name,Version,PackageFullName
Write-Header "Removing UWP Apps..."
$uwpApps = @(
"Microsoft.Messaging",
"king.com.CandyCrushSaga",
"Microsoft.BingNews",
"Microsoft.MicrosoftSolitaireCollection",
"Microsoft.People",
"Microsoft.WindowsFeedbackHub",
"Microsoft.YourPhone",
"Microsoft.MicrosoftOfficeHub",
"Fitbit.FitbitCoach",
"Microsoft.SkypeApp",
"Microsoft.GetHelp")
foreach ($uwp in $uwpApps)
{
Get-AppxPackage -Name $uwp | Remove-AppxPackage
}
Write-Header "Enable Windows 10 Developer Mode..."
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\AppModelUnlock" /t REG_DWORD /f /v "AllowDevelopmentWithoutDevLicense" /d "1"
Write-Header "Enable Remote Desktop..."
Set-ItemProperty "HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\" -Name "fDenyTSConnections" -Value 0
Set-ItemProperty "HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp\" -Name "UserAuthentication" -Value 1
Enable-NetFirewallRule -DisplayGroup "Remote Desktop"
if (!$(Check-Command "choco"))
{
Write-Header "Installing Chocolatey"
Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
}
Write-Header "Installing Chocolatey packages"
cinst -y .\packages.config
Write-Header "Installing Windows Features"
cinst -y .\features.config -s windowsFeatures
if (Check-Command "wsl")
{
Write-Header "Setting WSL 2 as default version"
wsl --set-default-version 2
$distroList = $(wsl -l -q)
if (!$distroList)
{
Write-Header "Installing the latest openSUSE Tumbleweed WSL"
$appxPath = ".\tumbleweed-latest.Appx"
if (!$(Test-Path -Path $appxPath))
{
$baseUrl = "http://download.opensuse.org/repositories/Virtualization:/WSL/openSUSE_Tumbleweed/"
$resp = $r = iwr $baseUrl -UseBasicParsing
$appx = $($resp.Links | ?{$_.href -Match ".Appx$"})[0].href
$appxUrl = -join($baseUrl, $appx)
$progresspreference = 'silentlyContinue'
iwr $appxUrl -OutFile $appxPath
$progressPreference = 'Continue'
}
$certPath = ".\tumbleweed-latest.cer"
if (!$(Test-Path -Path $certPath))
{
$cert = $(Get-AuthenticodeSignature -FilePath $appxPath).SignerCertificate
Export-Certificate -Cert $cert -FilePath $certPath -Type CERT
}
Import-Certificate -FilePath $certPath -CertStoreLocation Cert:\LocalMachine\Root
Add-AppxPackage $appxPath
$installDir = $(Get-AppxPackage | ?{$_.Name -match "Tumbleweed"})[0].InstallLocation
Start-Process -FilePath $(Join-Path $installDir "openSUSE-Tumbleweed") -Wait
rm $appxPath
rm $certPath
}
}