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

New-Item c:\VHD-staging -type directory

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

New-PSDrive -name P -psprovider FileSystem -root \\10.0.0.1\ShareName

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.

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

There you have it

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

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

Thanks for your time, and thanks for hanging out with me here.

from Rat’s Citrix Blog