Saturday, March 29, 2014

PowerShell 004 - Copy-VMFile

Working between Host and Guest Virtual Machines

I'm spending my Saturday watching a Virtual Academy session on Hyper-V. I am becoming a big fan of the Microsoft Virtual Academy (http://www.microsoftvirtualacademy.com). This session however is not great. I'm sticking in there optimistic that it will get better. It feels like I am watching a marketing person try to convince the audience how smart they are. I'm sure they are smart, I just want to learn more about Hyper-V. And I don't want to watch you read off of slides. Last critical piece, I promise! Showing a dialog box and talking about each and every button is not a demo! phew...

While listening in I am building up a new lab from scratch. Starting off with a Windows Server 2012 R2 DC. And as typically happens I forget everything I know about Hyper-V networking. I build a lab, get it setup, working great and then forget it for a few months. When it is time to build a new lab I forget it. It is a bit of a mental block for some reason. 

But this time I actually learned something cool, interesting and helpful. Believe it or not, it is a PowerShell cmdlet! Who would have thunk it?

Hyper-V in Windows 8.1 and Windows Server 2012 R2 is pretty amazing. Having Hyper-V on the client since Windows 8 has single handedly changed how I get things done. Its not always simple, but it is accessible and so much better than it used to be. 

Copy-VMFile


This is quick. I came across this cmdlet while reading a 'What's New in Hyper-V on Server 2012 R2' type article. I came across the Guest Services piece in Integration Services. A blurb from John Savill on windowsitpro.com mentioned a new cmdlet that I had not seen before.

A quick trip through help;

PS C:\psStuff> Get-Help Copy-VMFile -Full

And I found an easy way to move data from my machine to the VM using Guest Services. As you know -Full provides comprehensive help information as well as examples. This cmdlet only had one example but it was enough for me.

PS C:\psStuff> Copy-VMFile dc1 -SourcePath "c:\psstuff\test.txt" -DestinationPath "C:\From Host" -CreateFullPath -fileSource host

Easy peasy, as my daughters say! So if you are using Internal or Private Switches with Hyper-V to keep your test labs isolated and you want an easy way to move files over to those VMs, well there you go!

Enjoy!

No comments:

Post a Comment