I can build a VM from PowerCLI no problem, but I am having issues when adding a CD drive to the new VM, the CD adds just fine, and I have no issue attaching the ISO and setting the connected status however, when I boot the VM the CD is disconnected.
If the amend the setting from the gui I get the error message:
Reconfigure virtual machine
Connection control operation failed for disk 'ide0:0'.
My code is as follows:
$VM = "test"
New-VM -Name $VM `
-VMHost <host> `
-Datastore <DATASORE> `
-NumCPU 2 `
-MemoryGB 8 `
-DiskGB 120,12 `
-GuestId windows9Server64Guest `
-NetworkName NIC1 -Confirm:$false
Get-NetworkAdapter $VM | Set-NetworkAdapter -Type Vmxnet3 -Confirm:$false
New-CDDrive $VM -Confirm:$false -Verbose
Set-CDDrive -CD $Drive -StartConnected:$true -Confirm:$false -Verbose
Set-CDDrive -CD $Drive -IsoPath "[Datastore] ISO/Windows/SW_DVD9_Win_Server_STD_CORE_2019_64Bit_English_DC_STD_MLF_X21-96581.ISO" -Confirm:$false -Verbose
If I do all this manually there is no issue.
I tried that but it gives the same result. The CDROM is disconnected on boot up. I think it is the readonly setting for the CDROM, I saw this setting when I was trying ot get it to work and now I can't locate it.
Set-CDDrive is accepting any path, whether the path is valid or not.
Check if the ISO path is correct.
Path is case sensitive!
exactly ".ISO" must be ".iso". Perhaps there are more errors.
Tested on my system. By changing the correct path (.iso) to ".ISo". When connecting, I got an error:
Set-CDDrive Server task failed: Connection control operation failed for disk 'ide0:0'. Connection control operation failed for disk 'ide0:0'
Vcenter 7 ESXi 6.7 p02
Pwsh 7.2 PowerCli 12.5
In your example, there is a setup, but the connect status will be NotConnected.
I can create two files with the same names. Media-1.iso and media-1.iso.
Esxi it's a Linux system which is case sensitive.