VMware Cloud Community
VicMware
Contributor
Contributor

Copy file from desktop to virtual machine

Hi

Is there a way of copying a file from my desktop to a Virtual machine's D drive?

0 Kudos
4 Replies
mattboren
Expert
Expert

Hello, VicMware-

Yes, there are ways to do so.  One way is via UNC path to an administrative share (like "D$").  This way, of course, assumes that the VM is on the network.

Another way, which does not depend on the guest OS being able to communicate on the network, is using the Copy-VMGuestFile cmdlet.  A quick example:

## get credentials for some account in the guest OS
$credGuestUser = Get-Credential someLocalUser
## copy a file from the local machine to the given folder on 😧 in the guest
Copy-VMGuestFile -VM myVM0 -LocalToGuest -Source c:\temp\myFile.txt -Destination d:\someFolder\ -GuestCredential $credGuestUser

This relies on VMware Tools running in the guest OS.  See the cmdlet's help for other requirements/stipulations for using it.  How does that do for you?

0 Kudos
bairstowscott
Contributor
Contributor

Capture.PNG

$vm = Get-VM -Name 'vmname'
Get-Item "E:\ISOs\abc.txt" | Copy-VMGuestFile -Destination "D:\test" -VM $vm -LocalToGuest -GuestUser test -GuestPassword P@ssc0de

Hi

Its not working. I tried different local accounts and they all have adminitrator rights......

0 Kudos
avnish201110141
Contributor
Contributor

Please check Permission on Folder Test in 😧 drive  , this folder should have write rights.

0 Kudos
mattboren
Expert
Expert

Hello, bairstowscott-

One thing that comes to mind is:  does the folder "d:\temp" exist on the VM to which you are copying the file?  There is a -Force parameter to Copy-VMGuestFile that "indicates that the non-existing directories in the specified destination path are automatically created", which suggests that the default behavior is not to create non-existent folders in the destination path.

Another possiblity:  there is another thread with the same error message of "The guest authentication method being used does not have sufficient permissions to perform the operation" at http://communities.vmware.com/message/2149890.  It is not exactly the same situation (it is using a different cmdlet, but still one that interacts with a VM's guest OS), but it would be interesting to see if one of the last two posts have effect in your situation:  either a power off, power on of the VM, or (less disruptively) a vMotion operation of the VM in question.

Any different outcome after such efforts?

0 Kudos