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
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.
You can't have distinctive parameters from different parametersets in 1 call to the cmdlet.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
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
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
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.
You can't have distinctive parameters from different parametersets in 1 call to the cmdlet.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Oh, I see now. Thanks!