Hyper-V 2012 R2: copy file from host into guest VM

I wanted to move some policy definitions files from 2012 R2 to a domain joined VM.

I made a zip of the missing files and directly tried to use the new Copy-VMFile cmdlet of the Hyper-V module of Windows 2012 Server R2.

I got a little bit disappointed as my first attempt ended with the following error message:

Copy-VMFile : ‘GuestVMName’ failed to copy file. (Virtual machine ID a4391904-ba6c-462f-99e0-7abd1d90b0a5)
‘PRA406’ failed to initiate copying files to the guest: The device is not ready. (0x80070015). (Virtual machine ID
‘GuestVMName’: The ‘Guest Service Interface’ integration service is either not enabled, not running or not initialized.
(Virtual machine ID a4391904-ba6c-462f-99e0-7abd1d90b0a5)
The system cannot process the request at this time.

I thought the integration service weren’t upgraded, so I checked with the following command:

Get-VM | ? State -eq "Running" |            
Select Name,State,Integrationservicesversion |            
ft -AutoSize

If I had read more carefully the above message, I’d have found immediately that the ‘Guest Services’ weren’t enabled (confirmed by the UI)

Get-VM -Name GuestVMName |  Get-VMIntegrationService

Let’s enable it:

Get-VM -Name GuestVMName |             
Get-VMIntegrationService | ? {-not($_.Enabled)} |             
Enable-VMIntegrationService -Verbose

My second attempt with Copy-VMFile ran like a charm 😎

Copy-VMFile -Name GuestVMName -SourcePath $home\documents\policydefinitions.zip -DestinationPath C:\Users\administrator\documents -FileSource Host

1 thought on “Hyper-V 2012 R2: copy file from host into guest VM

  1. This is cool, it solved my hyper VM issue. I was also much troubled with copying files to my other VM. Hyper VM and this file transfer method is going to save a lot of my time.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.