From 5676dbb5541a5d5bb05cc42b52e60a0c2fbc8620 Mon Sep 17 00:00:00 2001 From: David Yoder Date: Thu, 19 Sep 2024 14:41:19 -0400 Subject: [PATCH] initial commit --- Enable-HyperVFeatures.ps1 | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 Enable-HyperVFeatures.ps1 diff --git a/Enable-HyperVFeatures.ps1 b/Enable-HyperVFeatures.ps1 new file mode 100644 index 0000000..1b21f60 --- /dev/null +++ b/Enable-HyperVFeatures.ps1 @@ -0,0 +1,14 @@ +# Exit if the endpoint is not running at least Windows 10 +If ( IsWindowsVersion -lt "10.0" ) { Return } + +# Exit if the endpoint is not running the Pro/Enterprise version of Windows +$Edition = ($(systeminfo | findstr /B /C:"OS Name") -replace "OS Name:","").Trim() +If ( ($Edition -notcontains "Pro") -and ($Edition -notcontains "Enterprise") ) { Return } + +# Exit if Hyper-V is already enabled +If ( (Get-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V).State -eq "Enabled" ) { Return } + +# Endpoint is running the correct version of Windows, enabling Hyper-V features +Write-Output "Enabling Hyper-V features" +Try { Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -All -NoRestart } +Catch { Write-Error $_.Exception.Message }