PowerCLI-Example-Scripts icon indicating copy to clipboard operation
PowerCLI-Example-Scripts copied to clipboard

Get-ContentLibrary & Get-ContentLibraryItemFiles - error when library not backed by datastore

Open amikkelsendk opened this issue 5 years ago • 0 comments

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

amikkelsendk avatar Apr 16 '19 08:04 amikkelsendk