Oct 12, 2011 at 1:04 PM

Hi Together.

I'm running a script which creates VIrtual Machines, in my Hyper V Settings the Default path for .vhd is set to E:\

I want that the scripts assign a new vhd to the new vm in a subfolder.

So  first i create the subfolder, and add the Complete Path to $vhdpath.

It works, he creates the vhd and assigns it to the vm, but he creates the VHD on E:\ and not, for example on E:\VM1\VM1.vhd

If i give out $vhdpath, it gives the correct path to the subfolder.

#VHD File Path
mkdir "$(get-VHDdefaultPath)\$VM"
$vhdPath = "$(get-VHDdefaultPath)\$VM\$VM.vhd"

# Add New VHD
Add-VMNewHardDisk -vm $VM -controllerID 0 -lun 0 -vhdpath $vhdpath -Size 20GB

So, is there any mistake from my site or is it a mistake in the Script?


Oct 24, 2011 at 8:37 AM

No ideas?