I was recently doing some work with the vSphere Content Library and I needed to extract some information using the Content Library API. I was hoping there were a few out of the box PowerCLI cmdlets but to my surprise, there was only one cmdlet called Get-ContentLibraryItem which did not get into the level of details that I was looking for, which was on a per-file level rather than item-level. I had also search the web to see if anyone had built any functions and although a few existed, none that did the very basics which was retrieving all libraries, library items and library item files.

UPDATE (11/14/17) - I have recently updated the Content Library module to enhance the Get-ContentLibrary function and added several additional functions listed below

  • Set-ContentLibrary
  • New-ExtReplicatedContentLibrary
  • Remove-SubscribedContentLibrary
  • New-LocalContentLibrary
  • Remove-LocalContentLibrary
  • Copy-ContentLibrary

Not having worked with the Content Library APIs before, I figure this would be a good learning opportunity and created a PowerCLI module called ContentLibrary.psm1 which contains the following functions:

  • Get-ContentLibrary
  • Get-ContentLibraryItems
  • Get-ContentLibraryItemFiles

Before you can make use of these functions, make sure to connect to the CIS endpoint of your vCenter Server using the Connect-CisServer cmdlet.

Here is a screenshot of the vSphere Web Client showing all available Content Libraries:

Here is an example of retrieving the same information using the following command:


Note: You also have the ability to filter for the name of a specific Content Library by using the -LibraryName parameter

Here is a screenshot of the vSphere Web Client showing the individual Items within a Content Library:

Here is an example of retrieving the same information using the following command:

Get-ContentLibraryItems -LibraryName Test

Note: You also have the ability to filter for the name of a specific Content Library Item by using the -LibraryItemName parameter

Although the granularity when using the vSphere Web Client is at a Content Library Item, using the Content Library API, you can get additional information on the Item itself which is then composed of a set of files. The following command will allow you to retrieve all Files or you can use -LibraryItemName parameter to filter on a specific Item.

Get-ContentLibraryItemFiles -LibraryName Test -LibraryItemName TinyVM

12 thoughts on “vSphere Content Library PowerCLI community module

    • You didn’t read the blog post, did you? 😉 The singular is OOTB cmdlet which doesn’t give too much info, I’ve implemented my own set of functions, hence plural

  1. Is there anyway we can convert the item in content-lib directly to usual template instead of converting it to the VM and the template because we use cloud-stack for our internal cloud which will see only items in VMs and templates folders and not in the content-library ..

    • No, there is not. A VM Template in Content Library is completely different than a traditional VM Template and even the way it is stored differs. My suggestion is for the solution to integrate w/Content Library APIs directly, so you benefit from using CL 🙂 rather than limiting it to what traditional templates can do and not taking advantage of what CL provides

  2. William,

    I’m not sure if this is possible but, at my previous job, I had written a PowerCLI Script to take our templates once a month, convert them to VMs, install the latest windows updates, and then convert it back to template. I’d like to do something similar with the Content Library. I know the VM cannot be converted within the library, but are there cmdlets to export the VM from the library and download the OVA? From there I can script deploying the OVA into vCenter, installing the required updates, etc. I’d also need a way to delete the existing item in the Content Library and then import the new VM, replicate it, etc.



    Ben Liebowitz

  3. Thank you for your work on this module. It gets me past a delegation issue I’m encountering when remotely running the default Get-ContentLibraryItem. But a new issue has arisen.

    When I use the Get-ContentLibraryItems function to get a content library template, the object type that comes back is [pscustomobject] (as you specify in the function) but that object type cannot be passed to a New-VM command with the -ContentLibraryItem flag. Here is the error…

    “Cannot bind parameter ‘ContentLibraryItem’. Cannot convert the “” value of type “System.Management.Automation.PSCustomObject” to type “VMware.VimAutomation.ViCore.Types.V1.ContentLibrary.ContentLibraryItem”.”

    Is there a way to get the object that comes back from the function to be in the ContentLibraryItem object type?

    • I’ve got this same issue

      I can’t use the Vmware provided cmdlet because i have a master lib and 2 subscribed libs within my Vmware deployment (so i have local to site libraries) so i can’t filter down to a specific Library and Item otherwise

      • My workaround ironically is to store the Get-ContentLibraryItems output to a variable e.g. $libitems, then call Get-ContentLibraryItem -Id $libitems.id and then carry on as before

  4. Is there a way to see the total uncommitted size of the drives from the contentlibraryitem? I know we can get this information from a template and surprised it’s not available when importing to contentlibrary. I need this so I can calculate any over commitment before deploying the VM from the contentlibrary.


  5. Hi William

    This is great functionality, thanks. I’m trying to go a bit further. Any hints or tips on how I can add an OVA/OVF to the Content Library using PowerShell?

Thanks for the comment!

This site uses Akismet to reduce spam. Learn how your comment data is processed.