< Back

New-Template

Sun Jan 19, 2020 7:01 pm

NAME 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>]





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

-Datastore <StorageResource>

Specifies the datastore or the datastore cluster where you want to store the new template.



Required? false

Position? named

Default value None

Accept pipeline input? False

Accept wildcard characters? true



-DiskStorageFormat <VirtualDiskStorageFormat>

Specifies the disk storage format of the new template. This parameter accepts Thin, Thick, and

EagerZeroedThick values.



Required? false

Position? named

Default value None

Accept pipeline input? False

Accept wildcard characters? false



-Location <VIContainer>

Specifies the location where you want to place the new template.



Required? true

Position? 3

Default value None

Accept pipeline input? True (ByValue)

Accept wildcard characters? true



-Name <String>

Specifies a name for the new template.



Required? true

Position? 1

Default value None

Accept pipeline input? False

Accept wildcard characters? 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.



Required? false

Position? named

Default value False

Accept pipeline input? False

Accept wildcard characters? 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.



Required? false

Position? named

Default value None

Accept pipeline input? False

Accept wildcard characters? true



-Template <Template>

Specifies a template you want to clone.



Required? true

Position? named

Default value None

Accept pipeline input? True (ByValue)

Accept wildcard characters? true



-TemplateFilePath <String>

Specifies the datastore path to the file you want to use to register the new template.



Required? true

Position? 2

Default value None

Accept pipeline input? False

Accept wildcard characters? false



-VM <VirtualMachine>

Specifies the virtual machine from which you want to create the new template.



Required? true

Position? 2

Default value None

Accept pipeline input? True (ByValue)

Accept wildcard characters? true



-VMHost <VMHost>

Specifies the host where you want to create the new template.



Required? true

Position? named

Default value None

Accept pipeline input? False

Accept wildcard characters? true



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



Required? false

Position? named

Default value $true

Accept pipeline input? False

Accept wildcard characters? false



-WhatIf [<SwitchParameter>]

Indicates that the cmdlet is run only to display the changes that would be made and actually no objects are

modified.



Required? false

Position? named

Default value False

Accept pipeline input? False

Accept wildcard characters? false



<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,

ErrorAction, ErrorVariable, WarningAction, WarningVariable,

OutBuffer, PipelineVariable, and OutVariable. For more information, see

about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).



INPUTS



OUTPUTS

The newly created Template object







NOTES









-------------------------- 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 LINKS

Online Version: https://code.vmware.com/doc/preview?id= ... plate.html

Get-Template

Remove-Template

Set-Template