Copy vhd's to your Hyper-V server via Powershell

What do you do if you want to copy your vhd's from a share to your storage on your Hyper-V server?

I guess cut and paste...

What if you don't want to get your fingers all sticky from the GUI?

Lets try some powershell:

First lets create the directory so wh acn have a copy of the vhd's where we want it. Lets create a folder in the c:\ drive called VHD-staging

{code}
New-Item c:\VHD-staging -type directory
{code}

Great now we have a directory.
Now lets connect to the share:

{code}
New-PSDrive -name P -psprovider FileSystem -root \\10.0.0.1\ShareName
{code}

Now we have a connection to the share on the P drive.

The last step is to recursively copy the vhd's and any configuration files, snapshots etc.

{code}
Copy-Item -rec -filter * p:\ c:\VHD-staging
{code}

There you have it
{code}
New-Item c:\VHD-staging -type directory
New-PSDrive -name P -psprovider FileSystem -root \\10.0.0.1\ShareName
Copy-Item -rec -filter * p:\ c:\VHD-staging
{code}

Quick steps to create a folder, connect to a share and copy the contents.

Desktop Delivery: 
Virtualization Servers and Hosts: 
Microsoft Server Products: 
Powered by Drupal