From c3abae0aa9ffa0cb8186a9591b7a08421282c4ad Mon Sep 17 00:00:00 2001 From: "Kenneth Benzie (Benie)" Date: Fri, 9 Aug 2024 11:29:38 +0100 Subject: [PATCH] Update bootstrap-Windows.ps1 script * Add 1Password install step * Remove SSH key generation step * Remove SSH server step * Make 1Password, Hyper-V and Containers steps optional --- bootstrap-Windows.ps1 | 56 +++++++++++++++++++++++++------------------ 1 file changed, 33 insertions(+), 23 deletions(-) diff --git a/bootstrap-Windows.ps1 b/bootstrap-Windows.ps1 index f1f83b9..5f80281 100644 --- a/bootstrap-Windows.ps1 +++ b/bootstrap-Windows.ps1 @@ -1,26 +1,36 @@ -[CmdletBinding()] -Param( - [Parameter(Mandatory=$true)] - [String]$email, - [String]$sshKeyType = "ed25519" -) +$choices = '&Yes', '&No' + +# Install 1Password +$decision = $Host.UI.PromptForChoice('Install 1Password', 'Proceed?', $choices, 0) +if ($decision -eq 0) { + $1password_installer = "$env:USERPROFILE/Downloads/1PasswordSetup-latest.exe" + Invoke-WebRequest -Uri "https://downloads.1password.com/win/1PasswordSetup-latest.exe" -OutFile "$1password_installer" + &$1password_installer + Remove-Item $1password_installer +} else { + echo 'Skipping 1Password' +} + +# Enable Hyper-V +$decision = $Host.UI.PromptForChoice('Enable Hyper-V', 'Proceed?', $choices, 0) +if ($decision -eq 0) { + Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -All +} else { + echo 'Skipping Hyper-V' +} + +# Enable Containters +$decision = $Host.UI.PromptForChoice('Enable Containers', 'Proceed?', $choices, 0) +if ($decision -eq 0) { + Enable-WindowsOptionalFeature -Online -FeatureName Containers -All +} else { + echo 'Skipping Containers' +} # Install Chocolatey -Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1')) +iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1')) -# Enable Hyper-V and containters -Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -All -Enable-WindowsOptionalFeature -Online -FeatureName Containers -All - -# Install OpenSSH and start service -choco install --yes "--package-parameters=/SSHServerFeature" openssh -Start-Service sshd -Set-Service -Name sshd -StartupType 'Automatic' - -# generate keys and authorize them -ssh-keygen -t "$sshKeyType" -C "$email" -f "$env:USERPROFILE/.ssh/$sshKeyType" -# TODO: authorize public key for admin - -# Install Windows-Terminal and Debian -choco install --yes microsoft-windows-terminal -wsl --install --distribution Debia +# # Install OpenSSH and start service +# choco install --yes "--package-parameters=/SSHServerFeature" openssh +# Start-Service sshd +# Set-Service -Name sshd -StartupType 'Automatic'