Skip to content

Instantly share code, notes, and snippets.

@gillissm
Last active February 24, 2023 05:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save gillissm/60f64ebed785af08e165fd30057deed7 to your computer and use it in GitHub Desktop.
Save gillissm/60f64ebed785af08e165fd30057deed7 to your computer and use it in GitHub Desktop.
Enables the optional Windows Features of Containers and Hyper-V as required for Docker usage in Windows mode.
Write-Host "Runnng this script will install/enable the optional Windows features of Hyper-V and Containers."
Write-Host "After the Windows features are enabled this script will force a system reboot." -ForegroundColor Magenta
if($(Get-WindowsOptionalFeature -FeatureName Microsoft-Hyper-V -Online).State -ieq 'disabled')
{
Write-Host "Installing Microsoft Hyper V feature." -ForegroundColor DarkCyan
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -All -NoRestart
}
if($(Get-WindowsOptionalFeature -FeatureName Containers -Online).State -ieq 'disabled')
{
Write-Host "Installing Containers feature." -ForegroundColor DarkCyan
Enable-WindowsOptionalFeature -Online -FeatureName Containers -All -NoRestart
}
$confirmation = Read-Host "A restart is required for the changes to take effect. Restart now (y/n)?"
if ($confirmation -ieq 'y') {
Restart-Computer -Force
}
else {
Write-Host "At a time convenient to you, restart the machine for the changes to take effect."
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment