VMware Cloud Community
Muhammedali
Contributor
Contributor

Copy-DatastoreItem -Recurse option for folders and child item

Hi I'm trying to copy folder with child folder and (multiple layers) and items from my local machine to VMServer datastore

The command i'm using is :

$source_BHMTest= "E:\Testing\*"

( i even used

$source_BHMTest= "E:\Testing\*.*"

$source_BHMTest= "E:\Testing\"

)

Copy-DatastoreItem -Item $source_BHMTest -Destination DSDrive:\Test -Recurse:$true -Confirm:$false -Force

The file transfer has intermintent errors as shown in fig attached

Any explanations?

0 Kudos
5 Replies
LucD
Leadership
Leadership

I normally do this as follows

$source_Dir= "C:\TestFolder\"

$datastore = Get-Datastore MyDS
New-PSDrive -Location $datastore -Name ds -PSProvider VimDatastore -Root '\'
Copy-DatastoreItem -Item $source_Dir -Destination ds:\Test -Recurse:$true -Confirm:$false -Force
Remove-PSDrive -Name ds

And this works without a problem

Are there any VIX logs created ?

Have a look in %temp%\vmware-<useraccount>

The logs start with vmware-vix or vmware-vixWrapper.

You seem to have timeout problems on the VIX connection.

Are you sure you are using the latest PowerCLI build ?

Do a

Get-PowerCLIVersion

This should return

PowerCLI Version
----------------
   VMware vSphere PowerCLI 4.1 U1 build 332441


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
Muhammedali
Contributor
Contributor

Hi LucD,

I checked on the version of PCLI. Its v4.1 U1 build 332441

If i try sending one big file of 400MB, that goes well

but if i send a smaller size of 100KB having many sum folders and variety of files in it. It gives me the same error.

I check the logs and have attached one too..

p.s. on my VM i have CPLI v4.1 , VIX v1.10.2 installed. there is no vsphereClient v.4.1 installed on VM

0 Kudos
LucD
Leadership
Leadership

That's the current PowerCLI build.

That doesn't look like a Vix log.

Those normally start with something like this

Mar 05 11:35:16.688: app-15016| Log for Vix pid=7044 version=-1 build=build-255297 option=Release
Mar 05 11:35:16.688: app-15016| The process is 32-bit.
Mar 05 11:35:16.688: app-15016| Host codepage=windows-1252 encoding=windows-1252
Mar 05 11:35:16.688: app-15016| Foundry Init: setting up global state (0 threads)
Mar 05 11:35:16.704: app-15016| Vix_InitializeGlobalState: vixLogLevel = 0
Mar 05 11:35:16.704: app-15016| Vix_InitializeGlobalState: vixApiTraceLevel = 0
Mar 05 11:35:16.704: app-15016| Vix_InitializeGlobalState: vixDebugPanicOnVixAssert = 0
Mar 05 11:35:16.704: app-15016| Vix_InitializeGlobalState: vixLogRefcountOnFinalRelease = 0
Mar 05 11:35:16.704: app-15016| Vix_InitializeGlobalState: asyncOpWarningThreshold = 1000000
Mar 05 11:35:16.704: app-15016| Vix_InitializeGlobalState: enableSyncOpSelection = FALSE
Mar 05 11:35:16.704: app-15016| Vix_InitializeGlobalState: enableExternalThreadInterface = TRUE
Mar 05 11:35:16.704: app-15016| LOCALE windows-1252 -> NULL User=809 System=809

In the guest OS you only need the VMware tools.

Could indeed be a problem with the number of files and the size of the files.

Perhaps someone from the Dev Team can chime in.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
Muhammedali
Contributor
Contributor

Hi LucD,

Seems so, as u mentioned, Sometimes the file(s) copy goes on smoothly, sometimes it stops (copies just a few of them) with the error as mentioned before..

If i want to copy files from the VM Server Datastore to the VM's local drive, it should be possible with the following commands :

New-PSDrive -Location (Get-Datastore -Server $MyServer -Name "SAN2") -Name DSDrive -PSProvider VimDatastore -Root '\'

#copying files from VMData Store to a VM's local folder
$src = "DSDrive:\Test\MyTest\"            # on the DataStore
$des = "C:\Files\Testing\My_Testing\"   #on the VM
Copy-DatastoreItem -Item $src -Destination $des -Recurse:$true -Confirm:$false -Force

The commands works well without any error message. $? also returns True

But on the VM, at the folder "C:\Files\Testing\My_Testing\" I dont see any copied files

0 Kudos
LucD
Leadership
Leadership

The files will be copied to the machine where you run the script.

To copy files to/from the guest you will have to use the Copy-VMGuestFile cmdlet.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos