I am trying to create a CentOS image template and my environment requires me to add a route file to the networking which would be different on each deployment.

Is there any way for me to inject a file from a Hyper-V host to a ext4 formatted Linux guest VHD?

Ideally I'd like to be able to write to script the creation of a VM in Powershell by copying the template VHD and injecting the route file to the VHD.

Is this possible?

1 Answer 1


There are multiple ways to perform this.

If you have Linux Integration Services (LIS) installed, you can use the Copy-VMFile Cmdlet on the Hyper-V host where the VM is running to copy the files into the Linux VM. On the VM settings, you need to enable Guest Services.

Once you have the LIS installed in Linux guest and Guest Services enabled in VM settings, ensure that the hypervfcopyd is running inside the guest. You can, then, use the Copy-VMFile cmdlet.

Copy-VMFile -Name centos001n -SourcePath 'C:\Scripts\myPytonLib.tar' -DestinationPath '/home/ravi/scripts' -FileSource Host

There are, of course, other methods if you have network connectivity.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.