LabBuilder icon indicating copy to clipboard operation
LabBuilder copied to clipboard

Install-Lab doesn't detect if Hyper-V is missing

Open DennisL68 opened this issue 5 years ago • 1 comments

•PowerShell 5.1 •PowerShell Console as Administrator •Windows 10 b18362 •LabBuilder v1.0.4.84

If Install-Lab is run before Hyper-V has been setup, it will fail.

A suggestion is to check for Hyper-V and ask to set it up if it's missing.

DennisL68 avatar Oct 30 '19 18:10 DennisL68

This should do the trick

 $InstallHyperV = Get-WindowsOptionalFeature -Online -FeatureName 'Microsoft-Hyper-V*' |
    where State -ne 'Enabled' |
    Enable-WindowsOptionalFeature -Online -NoRestart

If ($InstallHyperV.RestartNeeded){
    Write-Host 'Computer needs to be restarted to activate Hyper-V'
    Exit
}#end check restart

DennisL68 avatar Feb 12 '20 09:02 DennisL68