VMware Cloud Community
tdubb123
Expert
Expert

changing from isopath to client device

how do I change all my vms from isopath to client device?

C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI
get-vm | where { $_ | get-cddrive | where { $_.ConnectionState.Connected -eq "true" -and $_.ISOPath -like "*.ISO*"} } | set-cddrive - .... ?
0 Kudos
4 Replies
NeilGingell
Contributor
Contributor

To do this in Powershell this is probably the cmdlet you're after:

http://www.vmware.com/support/developer/PowerCLI/PowerCLI41/html/Set-CDDrive.html

It sounds as though Set-CDDrive -HostDevice is what you're after. You should be able to find out the HostDevice string by using Get-CDDrive -VM name. You'll need to run this separately though as Set-CDDrive -HostDevice doesn't take piped commands I don't think.

I've not tested this but something like...

ForEach-Object ($VM in Get-VM){
     $Drive = Get-CDDrive -VM $VM   
     Set-CDDrive -CD $Drive
}

Hope this helps.

0 Kudos
LucD
Leadership
Leadership

I'm afraid that is a feature of the vSphere Client, there is no cmdlet nor API to set the CD to the client device.


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

0 Kudos
mattboren
Expert
Expert

Hello, tdubb123-

I think that you are saying that you want to set the CDDrive to "Client Device" in the "Device Type" section of th settings of a VM in the vSphere client (effectively, disconnecting the CDDrive from anything).  If so, you can do that Set-CDDrive -- you almost had it.  Like:

Get-VM | Get-CDDrive | ?{$_.ConnectionState.Connected -and ($_.ISOPath -like "*.ISO*")} | Set-CDDrive -NoMedia -Confirm:$false

Like LucD said, though, if you are wanting to connect the CDDrives to a device on your client (an ISO local to your workstation, for example), there is no PowerCLI/API way to do so.

Message was edited by mattboren -- had left off the portion to check that the ISOPath was like the given string.  Updated.

0 Kudos
NeilGingell
Contributor
Contributor

Sorry - I missread the original post as host device, not client device.

0 Kudos