RedLenses
Contributor
Contributor

PowerCLI adding CD/DVD

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:
Task name
Reconfigure virtual machine
Target
testVM
Status
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 `
-MemoryHotAddEnabled:$true `
-CpuHotAddEnabled:$true `
-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. 

Any ideas?

0 Kudos
14 Replies
LucD
Leadership
Leadership

Add the StartConnected switch on the Set-CDDrive where you attach the ISO


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
RedLenses
Contributor
Contributor

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.

0 Kudos
LucD
Leadership
Leadership

Since you also seem to get an error when you do the same from the Web client, there might indeed be an issue with the ISO.
Did you already try with another ISO?
Did you check the vpxd log?

You can open an SR.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
Macleud
Enthusiast
Enthusiast

Hi.

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.

0 Kudos
LucD
Leadership
Leadership

Afaik the ISO path is not case-sensitive.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
Macleud
Enthusiast
Enthusiast

Hi LucD.

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

 

0 Kudos
LucD
Leadership
Leadership

Tested as well, changed ubuntu to Ubuntu, no problem whatsoever.
My ISO is located on a datastore.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
RedLenses
Contributor
Contributor

Thank you for your help - It would seem I have been staring at my screen for too long and was adding a non-existent iso! Uh boy.

0 Kudos
Macleud
Enthusiast
Enthusiast

I also datastore wmfs 6.83
Has your virtual machine been poweredOff?

Here is an example of an error.

error_iso.png

0 Kudos
LucD
Leadership
Leadership

I tested with all parts of the datastore path (datastore name, folder name, file name, file type), no case-sensitivity.

PSv5.1

cdpsv5.png

PSv7

cdpsv7.png

Afaik, there is no case-sensitivity in PowerCLI, except for the names of Advanced Settings.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
Macleud
Enthusiast
Enthusiast

Power On the vm. And add -connected $true
It adds a path to the iso.
But it is impossible to make a connected.

0 Kudos
LucD
Leadership
Leadership

Adding -Connected:$true makes no difference at all.
And the VM is powered on (otherwise -Connected would not work).



Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
Macleud
Enthusiast
Enthusiast

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.

error-2.png

Datastore.png

0 Kudos
LucD
Leadership
Leadership

Not true

connected.png

What does ESXi have to do with this, I'm connected to a VCSA.

And I'm going to stop this useless discussion.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos