Fix for: [hyperv]: VM import process does not respect Secure Boot option from image #5209
This commit is contained in:
parent
a2322c489e
commit
21e2f33fb0
|
@ -90,6 +90,9 @@ Switch ((Select-Xml -xml $vmconfig -XPath "//boot").node.device0."#text") {
|
|||
"Default" { $bootdevice = "IDE" }
|
||||
} #switch
|
||||
|
||||
# Determine secure boot options
|
||||
$secure_boot_enabled = (Select-Xml -xml $vmconfig -XPath "//secure_boot_enabled").Node."#text"
|
||||
|
||||
# Define a hash map of parameter values for New-VM
|
||||
|
||||
$vm_params = @{
|
||||
|
@ -133,6 +136,13 @@ $vm | Set-VM @more_vm_params -Passthru
|
|||
# Add drives to the virtual machine
|
||||
$controllers = Select-Xml -xml $vmconfig -xpath "//*[starts-with(name(.),'controller')]"
|
||||
|
||||
# Set EFI secure boot
|
||||
if ($secure_boot_enabled -eq "True") {
|
||||
Set-VMFirmware -VM $vm -EnableSecureBoot On
|
||||
} else {
|
||||
Set-VMFirmware -VM $vm -EnableSecureBoot Off
|
||||
}
|
||||
|
||||
# A regular expression pattern to pull the number from controllers
|
||||
[regex]$rx="\d"
|
||||
|
||||
|
|
Loading…
Reference in New Issue