Skip to content

Commit

Permalink
Add operating system and edition checks to WSL, Docker, Hyper-V, and …
Browse files Browse the repository at this point in the history
…developer mode enable scripts
  • Loading branch information
thejsa committed Oct 26, 2018
1 parent ee2a2cf commit 969035c
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 36 deletions.
17 changes: 13 additions & 4 deletions scripts/Docker.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
Enable-WindowsOptionalFeature -Online -FeatureName containers -All
RefreshEnv
choco install -y docker-for-windows
choco install -y vscode-docker
if(
# 64-bit edition of Windows
[Environment]::Is64BitOperatingSystem -and
# Editions with Hyper-V
# (See also: https://docs.microsoft.com/en-gb/windows/desktop/api/sysinfoapi/nf-sysinfoapi-getproductinfo)
((Get-WmiObject Win32_OperatingSystem).OperatingSystemSKU -in 0x06, 0x10, 0x12, 0x50, 0x8, 0xC, 0x79, 0x7A, 0x04, 0x46, 0x48, 0x1B, 0x54, 0x7D, 0x81, 0x7E, 0x82, 0x0A, 0x0E, 0x2A, 0xA1, 0xA2, 0x30, 0x45, 0x31, 0x67, 0x18, 0x4F, 0x07, 0x0D, 0x01, 0x47, 0x1C) -and
# Windows 10 Anniversary Update or later
((Get-WmiObject Win32_OperatingSystem).BuildNumber -ge 14393)) {
Enable-WindowsOptionalFeature -Online -FeatureName containers -All
RefreshEnv
choco install -y docker-for-windows
choco install -y vscode-docker
}
16 changes: 15 additions & 1 deletion scripts/HyperV.ps1
Original file line number Diff line number Diff line change
@@ -1 +1,15 @@
choco install -y Microsoft-Hyper-V-All --source="'windowsFeatures'"
# Install Hyper-V
if(
# 64-bit edition of Windows
[Environment]::Is64BitOperatingSystem -and
# Editions with Hyper-V
# (See also: https://docs.microsoft.com/en-gb/windows/desktop/api/sysinfoapi/nf-sysinfoapi-getproductinfo)
((Get-WmiObject Win32_OperatingSystem).OperatingSystemSKU -in 0x06, 0x10, 0x12, 0x50, 0x8, 0xC, 0x79, 0x7A, 0x04, 0x46, 0x48, 0x1B, 0x54, 0x7D, 0x81, 0x7E, 0x82, 0x0A, 0x0E, 0x2A, 0xA1, 0xA2, 0x30, 0x45, 0x31, 0x67, 0x18, 0x4F, 0x07, 0x0D, 0x01, 0x47, 0x1C) -and
(
# Server 2008 or later
([Environment]::OSVersion.Version -ge (New-Object 'Version' 6,0) -and (Get-WmiObject Win32_OperatingSystem).ProductType -gt 1) -or
# Windows 8 or later on client operating systems
([Environment]::OSVersion.Version -ge (New-Object 'Version' 6,2))
)) {
choco install -y Microsoft-Hyper-V-All --source="'windowsFeatures'"
}
9 changes: 6 additions & 3 deletions scripts/RemoveDefaultApps.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ $applicationList = @(
"*.AdobePhotoshopExpress"
);

foreach ($app in $applicationList) {
removeApp $app
}
# If on Windows 8 / Server 2012 or later...
if([Environment]::OSVersion.Version -ge (New-Object 'Version' 6,2)) {
foreach ($app in $applicationList) {
removeApp $app
}
}
7 changes: 4 additions & 3 deletions scripts/SystemConfiguration.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@


#--- Enable developer mode on the system ---
Set-ItemProperty -Path HKLM:\Software\Microsoft\Windows\CurrentVersion\AppModelUnlock -Name AllowDevelopmentWithoutDevLicense -Value 1
# (if on Windows 8 / Server 2012 or later)
if([Environment]::OSVersion.Version -ge (New-Object 'Version' 6,2)) {
Set-ItemProperty -Path HKLM:\Software\Microsoft\Windows\CurrentVersion\AppModelUnlock -Name AllowDevelopmentWithoutDevLicense -Value 1
}
51 changes: 26 additions & 25 deletions scripts/WSL.ps1
Original file line number Diff line number Diff line change
@@ -1,30 +1,31 @@
choco install -y Microsoft-Windows-Subsystem-Linux --source="'windowsfeatures'"
if ((Get-WmiObject Win32_OperatingSystem).BuildNumber -ge 14316) {
choco install -y Microsoft-Windows-Subsystem-Linux --source="'windowsfeatures'"

#--- Ubuntu ---
# TODO: Move this to choco install once --root is included in that package
Invoke-WebRequest -Uri https://aka.ms/wsl-ubuntu-1804 -OutFile ~/Ubuntu.appx -UseBasicParsing
Add-AppxPackage -Path ~/Ubuntu.appx
# run the distro once and have it install locally with root user, unset password
#--- Ubuntu ---
# TODO: Move this to choco install once --root is included in that package
Invoke-WebRequest -Uri https://aka.ms/wsl-ubuntu-1804 -OutFile ~/Ubuntu.appx -UseBasicParsing
Add-AppxPackage -Path ~/Ubuntu.appx
# run the distro once and have it install locally with root user, unset password

RefreshEnv
Ubuntu1804 install --root
Ubuntu1804 run apt update
Ubuntu1804 run apt upgrade -y
RefreshEnv
Ubuntu1804 install --root
Ubuntu1804 run apt update
Ubuntu1804 run apt upgrade -y

<#
NOTE: Other distros can be scripted the same way for example:
<#
NOTE: Other distros can be scripted the same way for example:
#--- SLES ---
# Install SLES Store app
Invoke-WebRequest -Uri https://aka.ms/wsl-sles-12 -OutFile ~/SLES.appx -UseBasicParsing
Add-AppxPackage -Path ~/SLES.appx
# Launch SLES
sles-12.exe
# --- openSUSE ---
Invoke-WebRequest -Uri https://aka.ms/wsl-opensuse-42 -OutFile ~/openSUSE.appx -UseBasicParsing
Add-AppxPackage -Path ~/openSUSE.appx
# Launch openSUSE
opensuse-42.exe
#>
#--- SLES ---
# Install SLES Store app
Invoke-WebRequest -Uri https://aka.ms/wsl-sles-12 -OutFile ~/SLES.appx -UseBasicParsing
Add-AppxPackage -Path ~/SLES.appx
# Launch SLES
sles-12.exe
# --- openSUSE ---
Invoke-WebRequest -Uri https://aka.ms/wsl-opensuse-42 -OutFile ~/openSUSE.appx -UseBasicParsing
Add-AppxPackage -Path ~/openSUSE.appx
# Launch openSUSE
opensuse-42.exe
#>
}

0 comments on commit 969035c

Please sign in to comment.