New-Template Command | Vmware PowerCLI Reference

New-Template

This cmdlet creates a new template based on the specified virtual machine. You can also create a new template by cloning an existing one. You can also register an existing template to the vCenter Server inventory.

Syntax

New-Template
-Location < VIContainer >
-Template < Template >
-VMHost < VMHost >
[-Datastore < StorageResource > ]
[-DiskStorageFormat < VirtualDiskStorageFormat > ]
[-Name < String > ]
[-ProgressAction < ActionPreference > ]
[-RunAsync ]
[-Server < VIServer[] > ]
[CommonParameters]

Parameters

Required Parameter Name Type Position Features Description
required
Location VIContainer named
  • wildcards
Specifies the location where you want to place the new template.
required
Template Template named
  • pipeline
  • wildcards
Specifies a template you want to clone.
required
VMHost VMHost named
  • wildcards
Specifies the host where you want to create the new template.
optional Datastore StorageResource named
  • wildcards
Specifies the datastore or the datastore cluster where you want to store the new template.
optional DiskStorageFormat VirtualDiskStorageFormat named
Specifies the disk storage format of the new template. This parameter accepts Thin, Thick, and EagerZeroedThick values.
optional Name String named
Specifies a name for the new template.
optional ProgressAction ActionPreference named
optional RunAsync SwitchParameter named
Indicates that the command returns immediately without waiting for the task to complete. In this mode, the output of the cmdlet is a Task object. For more information about the RunAsync parameter run "help About_RunAsync" in the VMware PowerCLI console.
optional Server VIServer[] named
  • wildcards
Specifies the vCenter Server systems on which you want to run the cmdlet. If no value is provided or $null value is passed to this parameter, the command runs on the default servers. For more information about default servers, see the description of Connect-VIServer.
New-Template
[ -VM ] < VirtualMachine >
[ -Location ] < VIContainer >
-Name < String >
[-Datastore < StorageResource > ]
[-ProgressAction < ActionPreference > ]
[-RunAsync ]
[-Server < VIServer[] > ]
[CommonParameters]

Parameters

Required Parameter Name Type Position Features Description
required
VM VirtualMachine 1
  • pipeline
  • wildcards
Specifies the virtual machine from which you want to create the new template.
required
Location VIContainer 2
  • pipeline
  • wildcards
Specifies the location where you want to place the new template.
required
Name String named
Specifies a name for the new template.
optional Datastore StorageResource named
  • wildcards
Specifies the datastore or the datastore cluster where you want to store the new template.
optional ProgressAction ActionPreference named
optional RunAsync SwitchParameter named
Indicates that the command returns immediately without waiting for the task to complete. In this mode, the output of the cmdlet is a Task object. For more information about the RunAsync parameter run "help About_RunAsync" in the VMware PowerCLI console.
optional Server VIServer[] named
  • wildcards
Specifies the vCenter Server systems on which you want to run the cmdlet. If no value is provided or $null value is passed to this parameter, the command runs on the default servers. For more information about default servers, see the description of Connect-VIServer.
New-Template
[ -TemplateFilePath ] < String >
-Location < VIContainer >
-VMHost < VMHost >
[-Name < String > ]
[-ProgressAction < ActionPreference > ]
[-RunAsync ]
[-Server < VIServer[] > ]
[CommonParameters]

Parameters

Required Parameter Name Type Position Features Description
required
TemplateFilePath String 1
Specifies the datastore path to the file you want to use to register the new template.
required
Location VIContainer named
  • wildcards
Specifies the location where you want to place the new template.
required
VMHost VMHost named
  • pipeline
  • wildcards
Specifies the host where you want to create the new template.
optional Name String named
Specifies a name for the new template.
optional ProgressAction ActionPreference named
optional RunAsync SwitchParameter named
Indicates that the command returns immediately without waiting for the task to complete. In this mode, the output of the cmdlet is a Task object. For more information about the RunAsync parameter run "help About_RunAsync" in the VMware PowerCLI console.
optional Server VIServer[] named
  • wildcards
Specifies the vCenter Server systems on which you want to run the cmdlet. If no value is provided or $null value is passed to this parameter, the command runs on the default servers. For more information about default servers, see the description of Connect-VIServer.

Output

VMware.VimAutomation.ViCore.Types.V1.Inventory.Template

Examples

Example 1

$myVM = Get-VM -Name "MyVM1"
$drsCluster=Get-DatastoreCluster "MyDatastoreCluster"
New-Template -VM $myVM -Name "MyTemplate" -Datastore $drsCluster -Location Datacenter2

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

Example 2

$myFolder = Get-Folder -Name "MyFolder1"
New-Template -Name "MyTemplate1" -TemplateFilePath "[Storage1] templatefolder/template.vmtx" -Location $myFolder -VMHost (Get-VMHost)

Registers the existing MyTemplate1 template to a vCenter Server inventory folder by using the specified template file.

Example 3

$myTemplate = Get-Template -Name "MyTemplate1"
$myDs = Get-Datastore -Name "MyDatastore1"
New-Template -Template $myTemplate -Name "MyTemplate2" -Datastore $myDs -Location "Datacenter2"

Creates the MyTemplate2 template by cloning an existing template and stores the new template in the specified datastore in the Datacenter2 datacenter.

Related Commands

Template

This cmdlet retrieves the virtual machine templates available on a vCenter Server system.

This cmdlet moves virtual machine templates to another location.

This cmdlet creates a new virtual machine template.

This cmdlet removes the specified virtual machine templates from the inventory.

This cmdlet modifies the specified virtual machine template.