Created
June 14, 2023 00:01
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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