Hi all,
I've been using the REST API in vcenter 8 (update 2) to create VM's, and i'm struggling to get Secure Boot enabled. I've searched documentation but i just can't see how its done.
There isn't a whole lot of details out there that i could easily stumble on for creating VM's using the API anyhow, so i've posted my config below in case it helps people.
Does anyone know if its possible to set Secure Boot to on using the REST API ?
$BaseVMSpecs = @{
spec = @{
name = "VM_Test_01" # VM Name
guest_OS = "WINDOWS_SERVER_2025" # OS Version (WinSvr2025)
placement = @{
folder = "group-v123456" # Folder ID.
resource_pool = "resgroup-123456" # Resource pool ID.
datastore = "datastore-123456" # Datastore ID.
}
cpu = @{
count = 8 # Number of vCPUs.
}
memory = @{
size_MiB = 65536 # RAM (in MB)
}
scsi_adapters = @(
@{
type = "PVSCSI" # Paravirtual SCSI controller
scsi = @{
bus = 0
unit = 0
}
}
)
disks = @(
@{
type = "SCSI" # Disk type
new_vmdk = @{
capacity = 120 * 1024 * 1024 * 1024 # 120 GB
name = "disk0" # Disk name
datastore = "datastore-123456" # Same datastore as VM
}
}
)
nics = @(
@{
type = "VMXNET3" # Set NIC Type to VMXNet3
start_connected = $true # Make sure the NIC is connected when the VM Starts
backing = @{
type = "DISTRIBUTED_PORTGROUP" # Set the NIC Type to a distributed switch, not a standard switch.
network = "dvportgroup-123456" # Set the network to "dvportgroup-123456".
}
}
)
cdroms = @(
@{
type = "IDE" # Type of CD ROM drive.
backing = @{
type = "ISO_FILE" # Set to use ISO file.
iso_file = "[TEST_DS_1] ISOs/TEST_ISO.iso" # Specify the Path of the ISO we want to mount. Uses display name, not GUID's...
}
start_connected = $true # Set to connect at boot.
}
)
# boot_Options = @(
# @{
# firmware="EFI" #### DOESN'T WORK
# secureBoot= $true #### DOESN'T WORK
# }
# )
#
boot = @{
type="EFI" # Sets VM to UEFI, (BIOS is the other option...)
secure_boot = $true # Doesn't seem to do anything.
efi_legacy_boot= $false # Doesn't seem to do anything.
efi_secure_boot_enabled = $true # Doesn't seem to do anything..
}
}
}
# Create the VM using the above specs. Use the RESTAPI to do this.
$response = Invoke-RestMethod -Uri "$VC_Server/rest/vcenter/vm" -Method POST -Headers $headers -Body ($BaseVMSpecs | ConvertTo-Json -Depth 10)
Thanks !