CD Category | Vmware PowerCLI Reference

CD Category

Cmdlets are usually implemented around resource operations. The four basic operations are CREATE, READ, UPDATE and DELETE. This set of operations is known as CRUD. Most of the cmdlets support CRUD which are respectively cmdlets that start with the New/Get/Set/Remove cmdlet verbs but they also may have additional operations

Step 1: Retrieve a object by running a Get command

You can READ objects by using Get-CDDrive cmdlet. See example below:

# Connects to a vSphere server and retrieves the CD drive of the virtual machine named VM.

Get-VM -Name VM | Get-CDDrive

Step 2 : Run commands from the CRUD group

You can CREATE objects by using New-CDDrive cmdlet. See example below:

# Creates a CD drive on the specified virtual machine and attach an ISO image to it.

New-CDDrive -VM $vm -ISOPath "Path_to_ISO\test.iso"
You can UPDATE objects by using Set-CDDrive cmdlet. See example below:

# Creates a CD drive on the VM virtual machine and attaches testISO.iso, previously uploaded. Then disconnects the ISO.

$cd = New-CDDrive -VM VM -ISOPath "[sof-20666-esx:storage1] ISO\testISO.iso" Set-CDDrive -CD $cd -NoMedia
You can REMOVE objects by using Remove-CDDrive cmdlet. See example below:

# Removes all CD drives for the specified virtual machines and templates.

$cd = Get-CDDrive -VM $vm Remove-CDDrive -CD $cd