PowerCLI-Example-Scripts
PowerCLI-Example-Scripts copied to clipboard
Get-ContentLibrary & Get-ContentLibraryItemFiles - error when library not backed by datastore
Hi, When a Content Library is NOT backed by an vCenter datastore, the function throws an error
Get-ContentLibrary Replacing the 2 lines $datastoreService = Get-CisService com.vmware.vcenter.datastore $datastore = $datastoreService.get($library.storage_backings.datastore_id)
with $datastoreService = [void](Get-CisService com.vmware.vcenter.datastore) if($datastoreService){ $datastore = $datastoreService.get($library.storage_backings.datastore_id) } fixes the error, from showing
Get-ContentLibraryItemFiles Replacing the 2 lines $DatastoreID = $library.storage_backings.datastore_id.Value $Datastore = get-datastore -id "Datastore-$DatastoreID" -ErrorAction SilentlyContinue
with $DatastoreID = void if($DatastoreID){ $Datastore = get-datastore -id "Datastore-$DatastoreID" -ErrorAction SilentlyContinue } fixes the error, from showing
Regards A. Mikkelsen