Skip to content

Instantly share code, notes, and snippets.

@lamw
Created June 14, 2023 00:01
Show Gist options
  • Save lamw/9341943e85c9c852c65ee49044203423 to your computer and use it in GitHub Desktop.
Save lamw/9341943e85c9c852c65ee49044203423 to your computer and use it in GitHub Desktop.
Manually sync all items in a vSphere Content Library using the vCenter Server REST API and PowerCLI
Connect-CISServer -Server vcsa.primp-industries.local -User administrator@vsphere.local -Password VMware1!
# Name of your Content Library
$content_library_name = "TKG-Content-Library"
$contentLibraryService = Get-CisService com.vmware.content.library
$contentLibraryItemService = Get-CisService com.vmware.content.library.item
$subscribedLibraryItemService = Get-CisService com.vmware.content.library.subscribed_item
# Find Content Library matching name
foreach ($id in $contentLibraryService.list()) {
$cl = $contentLibraryService.get($id)
if($cl.name -eq $content_library_name) {
$clId = $id.value
break
}
}
# Get all Content Library Items
$clItems = $contentLibraryItemService.list($clId)
# Iterate through all Content Library Items and perform manual sync
foreach ($clItem in $clItems) {
Write-Host "Syncing $clItem ..."
$subscribedLibraryItemService.sync($clItem,$true,$null)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment