File tree Expand file tree Collapse file tree 1 file changed +16
-4
lines changed
packaging/chocolatey/crc/tools Expand file tree Collapse file tree 1 file changed +16
-4
lines changed Original file line number Diff line number Diff line change @@ -21,17 +21,29 @@ function Install-Hyperv {
21
21
if ($enabled ) {
22
22
Write-Host " Hyper-V is already enabled"
23
23
} else {
24
- Enable-WindowsOptionalFeature - Online - FeatureName Microsoft- Hyper- V - All - NoRestart | Out-Null
25
- Write-Host - ForegroundColor Red " Hyper-V has been enabled, please reboot to complete installation"
24
+ try {
25
+ Enable-WindowsOptionalFeature - Online - FeatureName Microsoft- Hyper- V - All - NoRestart | Out-Null
26
+ Write-Host - ForegroundColor Red " Hyper-V has been enabled, please reboot to complete installation"
27
+ }
28
+ catch {
29
+ Write-Host - ForegroundColor Red " Failed to enable Hyper-V, aborting installation"
30
+ Set-PowershellExitCode 1
31
+ }
26
32
}
27
33
}
28
34
" Server" {
29
35
$enabled = (Get-WindowsFeature - Name " Hyper-V" | Select-Object - ExpandProperty InstallState).ToString().Equals(" Installed" )
30
36
if ($enabled ) {
31
37
Write-Host " Hyper-V is already enabled"
32
38
} else {
33
- Install-WindowsFeature - Name Hyper- V - IncludeManagementTools - Confirm:$false - Restart:$false | Out-Null
34
- Write-Host - ForegroundColor Red " Hyper-V has been enabled, please reboot to complete installation"
39
+ try {
40
+ Install-WindowsFeature - Name Hyper- V - IncludeManagementTools - Confirm:$false - Restart:$false | Out-Null
41
+ Write-Host - ForegroundColor Red " Hyper-V has been enabled, please reboot to complete installation"
42
+ }
43
+ catch {
44
+ Write-Host - ForegroundColor Red " Failed to enable Hyper-V, aborting installation"
45
+ Set-PowershellExitCode 1
46
+ }
35
47
}
36
48
}
37
49
}
You can’t perform that action at this time.
0 commit comments