Wednesday, June 18, 2014

Directly copy files from a Hyper-V host to a virtual machine on Windows Server 2012 R2 and Windows 8.1

In Windows Server 2012 R2 and Windows 8.1 with Hyper-V role, administrators can perform "Copy-VMFile" cmdlet to directly copy files from a Hyper-V host which is installed Windows Server 2012 or Windows 8.1 with Hyper-V role to a virtual machine without using a network connection. To copy files to a virtual machine, make sure virtual machines have been installed latest "Integration Services". After that, enable "Guest services" in a virtual machine.

By default, "Guest services" isn't enabled in a virtual machine. Administrators have to enable it by GUI or PowerShell before copying a file. To enable it by PowerShell, administrators can perform "Get-VMIntegrationService -VMName <Virtual Machine Name> -Name "Guest Service Interface" | Enable-VMIntegrationService -Passthru" cmdlet to enable "Guest services".

Then, Administrators can perform "Copy-VMFile -VMName <Virtual Machine Name> -SourcePath <The file path of a Hyper-Host> -DestinationPath <The destination file path of a virtual machine> -CreateFullPath -FileSource Host" to create and copy a file to a virtual machine.

Remark: "Copy-VMFile" can only copy 1 file per each time.

Administrators can use "Copy-VMFile GUI" which was written by seji to copy files from a Hyper-V host to a virtual machine. "Copy-VMFile GUI" is based on "Copy-VMFile" but it can add multiple files to copy to a virtual machine.

When all files have been copied to a virtual machine, administrators  should to disable the "Guest Services". To disable the service by PowerShell, administrators can perform "Get-VMIntegrationService -VMName <Virtual Machine Name> -Name "Guest Service Interface" | Disable-VMIntegrationService -Passthru" to disable it.

More information

This posting is provided “AS IS” with no warranties, and confers no rights!

No comments:

Post a Comment