PowerCLI cmdlet Copy-DatastoreItem does not function as expected to vSAN datastore
search cancel

PowerCLI cmdlet Copy-DatastoreItem does not function as expected to vSAN datastore


Article ID: 326992


Updated On:


VMware vSAN VMware vSphere ESXi


  • PowerCLI cmdlet Copy-DatastoreItem returns an error when attempting to copy files to a vSAN datastore.
Copy-DatastoreItem : Upload of file 'C:\filename.ext' failed. Error message: Error while copying
content to a stream.
At line:1 char:1
+ Copy-DatastoreItem -Item c:\FileZilla_3.46.2_win64-setup.exe "vmstore ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Copy-DatastoreItem], VimException
    + FullyQualifiedErrorId : Client20_StorageServiceImpl_UploadFile_UploadFailed,VMware.VimAutomation.ViCore.Cmdlets.

When attempting to copy a file to a folder on a vSAN datastore, an error is returned.

Copy-DatastoreItem : 2/20/2020 1:18:58 PM       VimDatastore            The specified location '\LastConnectedVCenterServer\Datacenter_name\vsanDatastore\folder_name' does not exist.
At line:1 char:1
+ Copy-DatastoreItem -Item c:\filename.ext "vmstore ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (:) [Copy-DatastoreItem], PathException
    + FullyQualifiedErrorId : Core_VmStoreProviderCache_GetItem_ObjectNotFound,VMware.VimAutomation.ViCore.Cmdlets.Commands.CopyDatastoreItem


VMware vSAN 8.0.x
VMware vSAN 6.x
VMware vSAN 7.0.x


It is not possible to copy a file to the root folder of a vSAN datastore, as it is an object-based, and not a file-based, distributed storage system. Files must be placed in a folder (namespace object). A file upload in GUI must be to a specified target folder.

Upload Files or Folders to vSAN Datastores


In order to copy files to or from a vSAN datastore folder using Copy-DatastoreItem, specify the object UUID of the target folder in the cmdlet.

The VMware code site contains a sample code function to list vSAN datastore folder friendly names and UUID.


Example usage of the Get-VSANDatastoreFolders function with Copy-DatastoreItem cmdlet:

PS C:\Windows\system32> $datastore = Get-Datastore -Name vsanDatastore
PS C:\Windows\system32> Get-VSANDatastoreFolders -Datastore $datastore -Server

Name                                                       Path
----                                                       ----
folder1                                            [vsanDatastore] e0ebba5d-fbb2-2e01-3db4-c81f66d017ad
folder2                                            [vsanDatastore] ad95335e-a286-2b03-1b14-74867aec662e

PS C:\Windows\system32> Copy-DatastoreItem  c:\filename.ext vmstore:\Datacenter_name\vsanDatastore\e0ebba5d-fbb2-2e01-3db4-c81f66d017ad\filename.ext

NOTE: The only approved method for migrating VMs to and from vSAN is storage vMotion. The above method is not to be used when migrating VMs to and from vSAN.

Additional Information