Is there a way to do this through script? So I can mount the same iso to multiple vm's at once?
I've tried: get-cddrive vm_name | set-cddrive -isopath "vm_templates\iso-files\whatever\whatever.iso"
But it continues to error out with an invalid datastore message. Any ideas?
The datastore path has to follow a specific syntax.
Like this
Get-CDDrive vm_name | Set-CDDrive -IsoPath "[datastorename] Folder\file.iso"
Don't forget the blank after the closing square bracket !
____________
Blog: LucD notes
Twitter: lucd22
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
The datastore path has to follow a specific syntax.
Like this
Get-CDDrive vm_name | Set-CDDrive -IsoPath "[datastorename] Folder\file.iso"
Don't forget the blank after the closing square bracket !
____________
Blog: LucD notes
Twitter: lucd22
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks Luc, that works. Another issues I'm having is actually connecting the cd rom.
Get-CDDrive vm_name | Set-CDDrive -StartConnected:$true -Connected:$true -IsoPath "[vm_templates] files\file.iso" -Confirm:$false
When I go in and edit the vm I can see the cdrom has "Connect at power on" checked but the "Connected" field is not checked. I thought the -Connected:$true would do that but apparently not. Am I missing something?
I just tried it like this and that works
Get-CDDrive vm_name | Set-CDDrive -StartConnected:$true -Connected:$true -IsoPath "vm_templates files\file.iso" -Confirm:$false
What state is the CDRom in before you do this ?
And can you also display the state of the CDRom after the first line
Can you do
Get-CDDrive vm_name | Select * Get-CDDrive vm_name | Set-CDDrive -StartConnected:$true -Connected:$true -IsoPath "vm_templates files\file.iso" -Confirm:$false Get-CDDrive vm_name | Select *
____________
Blog: LucD notes
Twitter: lucd22
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Here is the output that I got. For some reason it just doesn't seem to be connecting it. If I go into the guest OS and click on the cd-rom it acts like theres no disk inserted. If I go and edit the vm and click the "Connected" field and go back into the guest os the cd loads fine.
IsoPath : /vm_templates/ files/file.iso
HostDevice :
RemoteDevice :
ParentId : VirtualMachine-vm-85751
ConnectionState : VMware.VimAutomation.Client20.ConnectInfoImpl
Id : VirtualMachine-vm-85751/3000
Name : CD/DVD Drive 1
IsoPath : /vm_templates/ files/file.iso
HostDevice :
RemoteDevice :
ParentId : VirtualMachine-vm-85751
ConnectionState : VMware.VimAutomation.Client20.ConnectInfoImpl
Id : VirtualMachine-vm-85751/3000
Name : CD/DVD Drive 1
IsoPath : /vm_templates/ files/file.iso
HostDevice :
RemoteDevice :
ParentId : VirtualMachine-vm-85751
ConnectionState : VMware.VimAutomation.Client20.ConnectInfoImpl
Id : VirtualMachine-vm-85751/3000
Name : CD/DVD Drive 1
Note: replaced with /vm_templates/ since the board modifies it.
What does the connection state say.
Can you do
Get-CDDrive vm_name | Select -ExpandProperty ConnectionState Get-CDDrive vm_name | Set-CDDrive -StartConnected:$true -Connected:$true -IsoPath "vm_templates files\file.iso" -Confirm:$false Get-CDDrive vm_name | Select -ExpandProperty ConnectionState
____________
Blog: LucD notes
Twitter: lucd22
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
AllowGuestControl Connected StartConnected
True False True
True False True
Perhaps a stupid question but is the guest powered on ?
____________
Blog: LucD notes
Twitter: lucd22
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Yep.
Is the guest perhaps stuck in a "Installing VMware Tools" process ?
You should be able to see from the vSphere client.
____________
Blog: LucD notes
Twitter: lucd22
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Nope, doesn't look like it.
I'm out of ideas I'm afraid
Do you have this on all guests ? Can you try on another guest ?
____________
Blog: LucD notes
Twitter: lucd22
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I am experiencing the same issue actually. The VMs are powered on. ESX host, VC Server & Client at 4.0u1.
Get-PowerCLIVersion
PowerCLI Version
-
VMware vSphere PowerCLI 4.1 build 264274
$cd = Get-CDDrive ARCA
$cd | select *
IsoPath :
HostDevice :
RemoteDevice :
ParentId : VirtualMachine-vm-340
Parent : ARCA
ConnectionState : VMware.VimAutomation.ViCore.Impl.V1.ConnectInfoImpl
ExtensionData : VMware.Vim.VirtualCdrom
Id : VirtualMachine-vm-340/3002
Name : CD/DVD Drive 1
Uid : /VIServer=supermlc2024@fwdcwpappvct02:443/CDDrive=VirtualMach
ine-vm-340&slash;3002/
$cd.ConnectionState
AllowGuestControl Connected StartConnected
-
-
-
True False True
Set-CDDrive -CD $cd -IsoPath "[FTWCPCS04DS00] Software/9.1.19 SMP OS iso/SMPP91_8KS_20100709u19.iso" -Connected:$true -startconnected:$true -Confirm:$false
Iso HostDevice RemoteDevice
--- -
-
$cd = Get-CDDrive ARCA
$cd.ConnectionState
AllowGuestControl Connected StartConnected
-
-
-
True False True
We are trying to mount the ISO on 19 different VMs and none of them will go "Connected" via PowerCLI script. You can manually tick the box and they connect fine however. VMTools shows "OK", so I do not think it is an issue with the tools being mounted.
Any assistance would be greatly appreciated. Thanks!
Set-CDDrive -CD $cd -IsoPath "[FTWCPCS03DS00] Software/9.1.19 SMP iso/SMPP91_16KS_20100709u19.iso" -Connected $true -StartConnected $true -Confirm:$false
This worked for me.
Wanted to bump this post as I am having the same problems with the powershell vi toolkit
If i do the command
Get-CDDrive some_vm | Set-CDDrive -StartConnected:$False
and
Get-CDDrive some_vm | Set-CDDrive -StartConnected:$True
I can see the Start connected tick box change in the virtual centre
If i try
Get-CDDrive some_vm | Set-CDDrive -Connected:$False
or
Get-CDDrive some_vm | Set-CDDrive -StartConnected:$True
Nothing happens in the virtual centre.
Any ideas?
This works for me with an ISO and a host device.
WHich PowerCLI version are you using ?
Get-PowerCLIVersion
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
In your last example you mention:
Get-CDDrive some_vm | Set-CDDrive -StartConnected:$True
I suppose you meant:
Get-CDDrive some_vm | Set-CDDrive -Connected:$True
Make sure your CD drive isn't set to client device.
PowerCLI Version
----------------
VMware vSphere PowerCLI 4.1 U1 build 332441
---------------
Snapin Versions
---------------
VMWare vSphere PowerCLI 4.1 U1 build 332441
Strange, for -Connected:$true and -StartConnected both seem to work for a CD that is configured with an ISO or as host device.
What do you see for the Get-CDDrive ?
Get-CDDrive some_vm | Select *
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Think I have worked this out, when specifying the .iso file on the datastore on a previous command I was using the wrong slashes
[datastore] somefolder\anotherfolder\mycd.iso
Is incorrect
[datastore] somefolder/anotherfolder/mycd.iso
is correct
Thanks for your help