Score:1

ISO not booting using powwercli

rs flag

Using below codes I am able to mount ISO to the CD drive of a VM and change the BootOrder of the VM


$CloneVM = Get-VM -Name "999_SW999OSTest_Clone"
$IsoPath = "[NPROD_LUN-01_DEV_3333] Patches/SW_DVD9_Win_Server_STD_CORE_2019_1809.2_64Bit_English_DC_STD_MLF_X22-18452.ISO"

        $CDDrive = Get-CDDrive -VM $CloneVM
        $CDDrive | Set-CDDrive -ISOPath $IsoPath -Confirm:$false -StartConnected:$true

code to change the boot order (done while server was powered Off)

$strVMName = "999_SW999OSTest_Clone"
$strBootNICDeviceName = "Network adapter 1"
$strBootHDiskDeviceName = "Hard disk 1"
$vm = Get-VM $strVMName

$intNICDeviceKey = ($vm.ExtensionData.Config.Hardware.Device | ?{$_.DeviceInfo.Label -eq $strBootNICDeviceName}).Key
$oBootableNIC = New-Object -TypeName VMware.Vim.VirtualMachineBootOptionsBootableEthernetDevice -Property @{"DeviceKey" = $intNICDeviceKey}

$intHDiskDeviceKey = ($vm.ExtensionData.Config.Hardware.Device | ?{$_.DeviceInfo.Label -eq $strBootHDiskDeviceName}).Key
$oBootableHDisk = New-Object -TypeName VMware.Vim.VirtualMachineBootOptionsBootableDiskDevice -Property @{"DeviceKey" = $intHDiskDeviceKey}
$oBootableCDRom = New-Object -Type VMware.Vim.VirtualMachineBootOptionsBootableCdromDevice

$spec = New-Object VMware.Vim.VirtualMachineConfigSpec -Property @{
    "BootOptions" = New-Object VMware.Vim.VirtualMachineBootOptions -Property @{
        BootOrder = $oBootableCDRom, $oBootableNIC, $oBootableHDisk
    }
}
$vm.ExtensionData.ReconfigVM_Task($spec)`

Output for BootOrder

BootDelay            : 0
EnterBIOSSetup       : False
EfiSecureBootEnabled : False
BootRetryEnabled     : False
BootRetryDelay       : 10000
BootOrder            : {VMware.Vim.VirtualMachineBootOptionsBootableCdromDevice, 4000, 2000}
NetworkBootProtocol  : ipv4

reference answer by @Gerald Schneider: Setting a VM boot CD via PowerCLI

The above code is working fine, but when I restarted the VM, it is not starting the boot process.

Please let me know what I am missing here

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.