## PowerCLI Reference

# New-Template

## Synopsis

This cmdlet creates a new virtual machine template.

Syntax

New-Template [-VM] <VirtualMachine> [-Name] <String> [-Location] <VIContainer> [-Datastore <StorageResource>] [-Server <VIServer[]>] [-RunAsync] [-WhatIf] [-Confirm] [<CommonParameters>]
New-Template [[-Name] <String>] [-Location <VIContainer>] [-VMHost <VMHost>] [-Datastore <StorageResource>] [-DiskStorageFormat <VirtualDiskStorageFormat>] -Template <Template> [-Server <VIServer[]>] [-RunAsync] [-WhatIf] [-Confirm] [<CommonParameters>]
New-Template [[-Name] <String>] [-Location <VIContainer>] -VMHost <VMHost> [-TemplateFilePath] <String> [-Server <VIServer[]>] [-RunAsync] [-WhatIf] [-Confirm] [<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

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. | false | 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 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.