Jump to content
Welcome to our new Citrix community!
  • 0

XenServer - Boot Mode: UEFI Boot - for machines created with Powershell API


Piotr Ostrowski

Question

Hi !

Went through the forum, and did not stumble upon any detail which will reveal how to be succesfull with creating a VM using the XenServerPSModule where the Boot Options for the VM is UEFI Boot.

There are no problems creating such VM's with GUI, but I'm looking for the way to get the same result with automated way...

The UEFI VM's which are created with GUI works.

 

Stumbled upon those two repos, which are very helpful to get some understanding about the API itself:

https://github.com/xapi-project/xen-api-sdk/blob/master/powershell/autogen/samples/AutomatedTestCore.ps1

https://github.com/ZachThurmond/Automated-XenServer-Labs/blob/master/AXL.ps1

but both of them uses the BIOS way...

 

If someone can assist me I would be a great help !

$ObjSourceTemplate = Get-XenVM -Name 'Windows 10 (64-bit)'

 

$VMName = 'w10TestUEFI'
$VMRAM = 4*1GB
$VMCPU = 4

 

New-XenVM -NameLabel $VMName `
          -MemoryTarget $VMRAM `
          -MemoryStaticMax $VMRAM `
          -MemoryDynamicMax $VMRAM `
          -MemoryDynamicMin $VMRAM `
          -MemoryStaticMin $VMRAM `
          -VCPUsMax $VMCPU `
          -VCPUsAtStartup $VMCPU `
          -HVMBootPolicy "BIOS order" `
          -HVMBootParams @{ order = "dc" } `
          -HVMShadowMultiplier 1 `
          -UserVersion 1 `
          -ActionsAfterReboot restart `
          -ActionsAfterCrash restart `
          -ReferenceLabel $ObjSourceTemplate.reference_label `
          -HardwarePlatformVersion 2 `
          -Platform @{ "cores-per-socket" = "$VMCPU"; hpet = "true"; pae = "true"; vga = "std"; nx = "true"; viridian_time_ref_count = "true"; apic = "true"; viridian_reference_tsc = "true"; viridian = "true"; acpi = "1" } `
          -OtherConfig @{ base_template_name = $ObjSourceTemplate.reference_label }

2021-11-14 20_13_17-Window.png

 

looks like that within the console it can be achieved this way:
xe vm-list name-label=test
xe vm-param-set uuid=[UUID] HVM-boot-params:firmware=uefi
xe vm-param-set uuid=[UUID] platform:secureboot=false

but how to achieve the same with PS from the SD

Link to comment

1 answer to this question

Recommended Posts

  • 0

looks like this is doing the trick

 

$AllDefaultXenTemplates = (Get-XenVM -ErrorAction SilentlyContinue | Where { $_.is_a_template -eq $True -and $_.other_config.default_template } | sort -Property name_label).name_label
$AllCustomXenTemplates = (Get-XenVM -ErrorAction SilentlyContinue | Where { $_.is_a_template -eq $True -and !($_.other_config.default_template) -and $_.is_a_snapshot -eq $False} | sort -Property name_label).name_label

$SourceTemplateName = $AllDefaultXenTemplates -match "Windows 10 \(64-bit\)"

#$SourceTemplateName = $DropDownTemplates.SelectedItem
#$ObjSourceTemplate = Get-XenVM -Name $SourceTemplateName.Count
$ObjSourceTemplate = Get-XenVM -Name 'Windows 10 (64-bit)'

$VMName = 'test'
$VMRAM = 2*1GB
$VMCPU = 4

#-HVMBootPolicy "BIOS order" `
#-HVMBootParams @{ order = "dc" } `

#-HVMBootPolicy "UEFI" `
#-HVMBootParams @{ firmware = "uefi" ; order = "dc" } `
New-XenVM -NameLabel $VMName `
          -MemoryTarget $VMRAM `
          -MemoryStaticMax $VMRAM `
          -MemoryDynamicMax $VMRAM `
          -MemoryDynamicMin $VMRAM `
          -MemoryStaticMin $VMRAM `
          -VCPUsMax $VMCPU `
          -VCPUsAtStartup $VMCPU `
          -HVMBootPolicy "BIOS order" `
          -HVMBootParams @{ order = "dc"; firmware = "uefi"} `
          -HVMShadowMultiplier 1 `
          -UserVersion 1 `
          -ActionsAfterReboot restart `
          -ActionsAfterCrash restart `
          -ReferenceLabel $ObjSourceTemplate.reference_label `
          -HardwarePlatformVersion 2 `
          -Platform @{ "cores-per-socket" = "$VMCPU"; hpet = "true"; pae = "true"; vga = "std"; nx = "true"; viridian_time_ref_count = "true"; apic = "true"; viridian_reference_tsc = "true"; viridian = "true"; acpi = "1" } `
          -OtherConfig @{ base_template_name = $ObjSourceTemplate.reference_label }

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...