VMware Cloud Community
Sunshine_S
Enthusiast
Enthusiast
Jump to solution

Update existing Content Library template by cloning a VM to content library

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

 

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

No, the ID will stay the same


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

View solution in original post

0 Kudos
3 Replies
LucD
Leadership
Leadership
Jump to solution

You have to use the REST API named com.vmware.vcenter.ovf.library-item
I
f you use the target.library_item_id parameter, the existing item will be overwritten.


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

0 Kudos
Sunshine_S
Enthusiast
Enthusiast
Jump to solution

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.

0 Kudos
LucD
Leadership
Leadership
Jump to solution

No, the ID will stay the same


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

0 Kudos