From 7c7f8d3fbf49e04ed6e3e72dbac104067091af5c Mon Sep 17 00:00:00 2001 From: jpgrall <33696799+jpgrall@users.noreply.github.com> Date: Fri, 30 Nov 2018 09:55:46 -0600 Subject: [PATCH] Update ContentLibrary.psm1 Adding logic incase backing isn't a datastore. --- Modules/ContentLibrary/ContentLibrary.psm1 | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Modules/ContentLibrary/ContentLibrary.psm1 b/Modules/ContentLibrary/ContentLibrary.psm1 index d85bd54..9a8574b 100644 --- a/Modules/ContentLibrary/ContentLibrary.psm1 +++ b/Modules/ContentLibrary/ContentLibrary.psm1 @@ -198,8 +198,14 @@ Function Get-ContentLibraryItemFiles { $contentLibraryItemStorageService = Get-CisService com.vmware.content.library.item.storage foreach($file in $files) { - $filepath = $contentLibraryItemStorageService.get($itemId, $($file.name)).storage_uris.AbsolutePath.split("/")[5..7] -join "/" - $fullfilepath = "[$($datastore.name)] $filepath" + if($contentLibraryItemStorageService.get($itemId, $($file.name)).storage_backing.type -eq "DATASTORE"){ + $filepath = $contentLibraryItemStorageService.get($itemId, $($file.name)).storage_uris.AbsolutePath.split("/")[5..7] -join "/" + $fullfilepath = "[$($datastore.name)] $filepath" + } + else{ + $fullfilepath = "UNKNOWN" + } + if(!$LibraryItemName) { $fileResult = [pscustomobject] @{ Name = $file.name; @@ -703,4 +709,4 @@ Function New-VMFromVMTX { Write-Host "`nDeploying new VM $NewVMName from VMTX Template $VMTXName ..." $results = $vmtxService.deploy($vmtxId,$vmtxDeploySpec) -} \ No newline at end of file +}