PowerCLI: Upload to Content Library using PowerCLI
Summary:
Basically was looking to upload an iso or ovf from my system not using the web client to content library. Couldn't find an example to upload from my local system only to have vCenter pull it from somewhere.
Details:
So I took VMware's example and added "PUSH" functionality to upload from my local system to the content library. Learned some interesting things in the process. Mainly related to OVF uploads. The content library service, or possibly something else, parses the OVF looking for the related files. Then the Content Library is instructed to essentially wait for those other files to be uploaded before it closes the upload task. Kinda interesting.
Anyway, the script is powershell core based, so compatible across all platforms.
Links:
Basically was looking to upload an iso or ovf from my system not using the web client to content library. Couldn't find an example to upload from my local system only to have vCenter pull it from somewhere.
Details:
So I took VMware's example and added "PUSH" functionality to upload from my local system to the content library. Learned some interesting things in the process. Mainly related to OVF uploads. The content library service, or possibly something else, parses the OVF looking for the related files. Then the Content Library is instructed to essentially wait for those other files to be uploaded before it closes the upload task. Kinda interesting.
Anyway, the script is powershell core based, so compatible across all platforms.
Links:
Comments
$URL = 'ds:///vmfs/volumes/58d2f02a-a6f12fc4-718b-0025b5501006/ISOs/NewISOFileForContent.iso'
but I get a error:
A server error occurred: 'com.vmware.vapi.std.errors.internal_server_error': Provider method implementation threw unexpected exception:
com.vmware.vapi.std.errors.InternalServerError (Server error id: 'vapi.bindings.method.impl.unexpected'). Check $Error[0].Exception.ServerError for more details.
At line:111 char:1
+ $ContentLibraryUpdateItem.add($newSessionId,$createFileSpec)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (:) [], CisServerException
+ FullyQualifiedErrorId : VMware.VimAutomation.Cis.Core.Types.V1.CisServerException
File upload session is initiated.
A server error occurred: 'com.vmware.vapi.std.errors.not_allowed_in_current_state': No files have been added to the session. (Server error id:
'com.vmware.vdcs.cls-main.update_session_no_files'). Check $Error[0].Exception.ServerError for more details.
At line:158 char:1
+ $ContentLibraryUpdateSession.complete($newSessionId)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (:) [], CisServerException
+ FullyQualifiedErrorId : VMware.VimAutomation.Cis.Core.Types.V1.CisServerException
the Item is created on the Content Library with 0 bytes
there is any I can change to be able to upload a ISO file to a Content Library from a datastore?
Again thanks a lot for your work.