6

I have a sneaking suspicion that this may be a bug, but I'm definitely willing to entertain the possibility that I'm doing things wrong.

I have a VMware virtual machine in $vm, and I'm trying to assign a boot CD for it. $vm is powered off.

The documented method seems pretty straightforward:

Set-CDDrive -CD (Get-CDDrive -vm $vm) -IsoPath "[datastorename] \whatever.iso" -StartConnected 1

Now, when I start the VM, it immediately tries to PXEboot. I turn off the machine, and in the vSphere client, I edit the VM's properties, go to "CD/DVD drive 1", and verify, "Device Status" has a checkmark next to "Connect at power on".

Here's the crazy thing. When I uncheck that box, then check it again, then start the VM, it boots from the ISO.

I've done it again and again, with the console open, with it closed, and every time, I can set the StartConnected flag on the CLI, and the GUI reflects the setting, but only after I mark the checkbox manually does it actually boot from the ISO.

Is there a step that I'm neglecting to perform in PowerCLI to get this setting to "take"?

Matt Simmons
  • 20,218
  • 10
  • 67
  • 114

2 Answers2

0

From the PowerCLI reference online, I see the following example (replace value after -ISOPath with your datastore and name/path for .iso file like so"[yourdatastore] IsoFolder\$iso"):

$cd = New-CDDrive -VM $vm -ISOPath "[sof-20666-esx:storage1] ISO\testISO.iso"
Set-CDDrive -CD $cd -StartConnected -Connected
bentek
  • 2,205
  • 1
  • 14
  • 23
0

The first backslash in the ISOPath may very well be the problem. I'm doing the exact same thing in our provisioning scripts, it looks like this:

Get-CDDrive $VM | Set-CDDrive -IsoPath "[DATASTORE] ISO\BOOT.ISO" -StartConnected:$true -Confirm:$false

Also, if you're providing boolean values to arguments that accept a boolean (like StartConnected), try to make it a habit to use a semi-colon like the example above. If you happen to have a Cmdlet of function that accepts more than one unnamed argument, your 1 may be mis-interpreted as a new argument in the function call, rather than the value of the argument you intended.

So, don't use -StartConnected 1, but rather use -StartConnected:1 or -StartConnected:$true.

Patrick
  • 364
  • 1
  • 6