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
$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?