PowerCLI Reference

New-Template

Synopsis

This cmdlet creates a new virtual machine template.

Syntax

New-Template [-Name] <String> [-VM] <VirtualMachine> [-Location] <VIContainer> [-Datastore <StorageResource>] [-RunAsync] [-Server <VIServer[]>] [-Confirm] [-WhatIf] [<CommonParameters>]

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

New-Template [[-Name] <String>] [-TemplateFilePath] <String> [[-Location] <VIContainer>] [-RunAsync] [-Server <VIServer[]>] -VMHost <VMHost> [-Confirm] [-WhatIf] [<CommonParameters>]

Related Commands

Online Version
Get-Template
Remove-Template
Set-Template

Detailed 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

NameTypeDescriptionRequired?Pipeline InputDefault Value
NameStringSpecifies a name for the new template.trueFalse
TemplateFilePathStringSpecifies the datastore path to the file you want to use to register the new template.trueFalse
VMVirtualMachineSpecifies the virtual machine from which you want to create the new template.trueTrue (ByValue)
LocationVIContainerSpecifies the location where you want to place the new template.trueTrue (ByValue)
ConfirmSwitchParameterIf 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.falseFalse
DatastoreStorageResourceSpecifies the datastore or the datastore cluster where you want to store the new template.falseFalse
DiskStorageFormatVirtualDiskStorageFormatSpecifies the disk storage format of the new template. This parameter accepts Thin, Thick, and EagerZeroedThick values.falseFalse
RunAsyncSwitchParameterIndicates 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.falseFalse
ServerVIServer[]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.falseFalse
TemplateTemplateSpecifies a template you want to clone.trueTrue (ByValue)
VMHostVMHostSpecifies the host where you want to create the new template.trueFalse
WhatIfSwitchParameterIndicates that the cmdlet is run only to display the changes that would be made and actually no objects are modified.falseFalse

Return Type

The newly created Template object

Notes

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.


Copyright © VMware, Inc. All rights reserved.