Syntax
New-Template [-Name] <String> [-VM] <VirtualMachine> [-Location] <VIContainer> [-Datastore <StorageResource>] [-RunAsync] [-Server <VIServer[]>] [-Confirm] [-WhatIf] [<CommonParameters>]Related Commands
Online VersionDetailed Description
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.Parameters
Name | Type | Description | Required? | Pipeline Input | Default Value |
---|---|---|---|---|---|
Name | String | Specifies a name for the new template. | true | False | |
TemplateFilePath | String | Specifies the datastore path to the file you want to use to register the new template. | true | False | |
VM | VirtualMachine | Specifies the virtual machine from which you want to create the new template. | true | True (ByValue) | |
Location | VIContainer | Specifies the location where you want to place the new template. | true | True (ByValue) | |
Confirm | SwitchParameter | If the value is $true, indicates that the cmdlet asks for confirmation before running. If the value is $false, the cmdlet runs without asking for user confirmation. | false | False | |
Datastore | StorageResource | Specifies the datastore or the datastore cluster where you want to store the new template. | false | False | |
DiskStorageFormat | VirtualDiskStorageFormat | Specifies the disk storage format of the new template. This parameter accepts Thin, Thick, and EagerZeroedThick values. | false | False | |
RunAsync | SwitchParameter | 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. | false | False | |
Server | VIServer[] | Specifies the vCenter Server systems on which you want to run the cmdlet. If no 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. | false | False | |
Template | Template | Specifies a template you want to clone. | true | True (ByValue) | |
VMHost | VMHost | Specifies the host where you want to create the new template. | true | False | |
WhatIf | SwitchParameter | Indicates that the cmdlet is run only to display the changes that would be made and actually no objects are modified. | false | False |
Return Type
The newly created Template objectNotes
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.