Hello, we have vcenter server 7.0.3. I'm trying to automate the update of a Content Library VM template using a local template. I see there is no PowerCLI cmd-let to accomplish this task, so I have used the vCenter code capture and I got this:
Provided you are referring to an OVF & OVA Template, you could do
$clName = 'clLib'
$clItemName = 'MyTemplate'
$templateName = 'NewTemplate'
$cl = Get-ContentLibrary -Name $clName
$template = Get-Template -Name $templateName
Get-ContentLibraryItem -ContentLibrary $cl -Name $clItemName |
Set-ContentLibraryItem -Template Template1
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Provided you are referring to an OVF & OVA Template, you could do
$clName = 'clLib'
$clItemName = 'MyTemplate'
$templateName = 'NewTemplate'
$cl = Get-ContentLibrary -Name $clName
$template = Get-Template -Name $templateName
Get-ContentLibraryItem -ContentLibrary $cl -Name $clItemName |
Set-ContentLibraryItem -Template Template1
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
ehi Luc, many thanks!
yes, in my case it's about OVF format. But frankly, any solution that allows me to update the CL template without deleting it and creating new one will do. If you say that the template format is better fine.. I can change it and will update the code that automates VMs deployment in all sites.
However, running your code I get:
Set-ContentLibraryItem : A parameter cannot be found that matches parameter name 'Template'.
At line:8 char:87
+ ... rary $cl -Name $clItemName | Set-ContentLibraryItem -Template $templa ...
+ ~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Set-ContentLibraryItem], ParameterBindingException
+ FullyQualifiedErrorId : NamedParameterNotFound,VMware.VimAutomation.ViCore.Cmdlets.Commands.ContentLibrary.SetContentLibraryItem
in fact a get-help to the commands tells me that the parameter template does not exist. I have PowerCLI 12.1.0 build 17009493
That parameter was introduced in PowerCLI 12.2.
We are currently at PowerCLI 13.0, perhaps you should consider an upgrade
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
...and yes!! Habemus cmd-let for that 😁 Thanks Luc as usual! If you pass by Rome you have a carbonara paid!