VMware Cloud Community
Chris1962
Contributor
Contributor
Jump to solution

How to create a template in a sub folder?

I have the following folder hierarchy

Templates

--- Project1Templates

I posted yesterday how to get a template from a sub folder in my cluster and got a correct response. I used that answer to try to "write" a template into the above folder heriarchy. I tried

$toFolder = Get-Folder -Name Templates | Get-Folder -Name Project1Templates

New-Template -VM $fromVM -Name $newTemplate -Location $toFolder -Datastore $ds -VMHost -$host -DiskStorageFormat Thin

I check all my parameters and they're correct. I get

New-Template : Parameter set cannot be resolved using the specified named param
eters.
At C:\MyPath\CloneVMToTemplate.ps1:39 char:13
+ New-Template <<<<  -VM $fromVM -Name $template -Location $Templates -DiskStor
ageFormat Thin -Confirm:$confirmBool -Whatif:$whatifBool
    + CategoryInfo          : InvalidArgument: (:) [New-Template], ParameterBi
   ndingException
    + FullyQualifiedErrorId : AmbiguousParameterSet,VMware.VimAutomation.ViCor
   e.Cmdlets.Commands.NewTemplate

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

What I was trying to say is that a cmdlet can have different parametersets.

Each parameterset has some distinctive parameters. In this case the VM parameter is from the parameterset I marked as 1, while DiskStorageFormat is from parameterset I marked as 2.

newtemplate.png

You can't have distinctive parameters from different parametersets in 1 call to the cmdlet.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

0 Kudos
4 Replies
LucD
Leadership
Leadership
Jump to solution

The New-Template cmdlet has 3 parametersets, and you are mixing specific parameters from different parametersets.

The VM and DiskStorageFormat parameters in your case.

When you base your template on an existing VM you can't change the diskformat.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
Chris1962
Contributor
Contributor
Jump to solution

New-Template -VM $fromVM -Name $newTemplate -Location $toFolder -Datastore $ds -VMHost -$host -DiskStorageFormat Thin

But I DO have those parameters! Like I said, I echo (write-host) beforehand and I see valid values.

Chris

0 Kudos
LucD
Leadership
Leadership
Jump to solution

What I was trying to say is that a cmdlet can have different parametersets.

Each parameterset has some distinctive parameters. In this case the VM parameter is from the parameterset I marked as 1, while DiskStorageFormat is from parameterset I marked as 2.

newtemplate.png

You can't have distinctive parameters from different parametersets in 1 call to the cmdlet.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
Chris1962
Contributor
Contributor
Jump to solution

Oh, I see now. Thanks!

0 Kudos