We need to periodically update our templates. We have automation in place to power on VMs, upgrade OS (or installed software), and power off the VMs. We can also mark them as templates using the same script. However, we do not use local templates. We export them to content library and users across the organization use the content library templates.
So basically, I need to convert the following GUI steps to PowerCLI:
<Right-click VM>
Clone as template to library
Template type - OVF
Clone as - Update existing template
Name - same as VM name that we are cloning
Select Library item (Library Item to update) - same as VM name that we are cloning
I know the command New-ContentLibraryItem but it does not have the "update existing" option
Is there any way to automate these steps?
Thanks
No, the ID will stay the same
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
You have to use the REST API named com.vmware.vcenter.ovf.library-item
If you use the target.library_item_id parameter, the existing item will be overwritten.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
We need to automate this to run once every month. I can store the IDs for all current library templates in a file and use them in the script. But will the IDs change each time the item is updated? If so, then we cannot automate this. Human intervention will be required every time to capture new IDs.
No, the ID will stay the same
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference