Question

I have a question: How to get a file from a VM runing on a VMware ESXi5.0 Examples: i have a file Test.txt in folder C:\Test in 'myVM'. This myVM running on a vSphere server run windowserver 2008R2. I want to get this file to my local computer. I tried this code on PowerCLI:

Connect-VIServer -Server 10.16.172.10
$datastore = Get-Datastore "myVM"
New-PSDrive -Location $datastore -Name ds -PSProvider VimDatastore -Root "\"
Set-Location ds:\myVM

But it can only access the storage of VMWware but not the file on a specific VM.

Then I have tried this one:

Copy-VMGuestFile -VM myVM -LocalToGuest -Source c:\... -Destination d:\... -HostUser abc -HostPassword abc

But the command did not work as expected, this error was returned: Copy-VMGuestFile The guest operations agent could not be contacted. I can't find any solution for it.

Does anyone can give me an idea? Thank you in advance.

Was it helpful?

Solution

Try -GuestToLocal instead of -LocalToGuest and make sure VMTools is installed and running. From the Copy-VMguestFile documentation:

GuestToLocal - Indicate that you want to copy a file from the guest operating system of the virtual machine to a local directory.

LocalToGuest - Indicate that you want to copy a file from a local directory to the guest operating system of the virtual machine.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top