Template Category | Vmware PowerCLI Reference

Template 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-Template cmdlet. See example below:

# Retrieves all virtual machine templates in the Datacenter datacenter, whose names start with "Web".

Get-Template -Name Web* -Location Datacenter

Step 2 : Run commands from the CRUD group

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

# Creates a template named MyTemplate from the MyVM1 virtual machine and stores it in the MyDatastoreCluster datastore cluster in the Datacenter2 datacenter.

$myVM = Get-VM -Name "MyVM1" $drsCluster=Get-DatastoreCluster "MyDatastoreCluster" New-Template -VM $myVM -Name "MyTemplate" -Datastore $drsCluster -Location Datacenter2
You can UPDATE objects by using Move-Template cmdlet. See example below:

# Moves the $template object into the $dest container object.

Move-Template -Template $template -Destination $dest
You can REMOVE objects by using Remove-Template cmdlet. See example below:

# Removes the virtual machine template saved in the $template variable.

Remove-Template -Template $template

Step 3: Explore More Related Commands:

Set-Template This cmdlet modifies the specified virtual machine template.