@Kasper Johansen be careful with this... it assumes that the virtual disk attached is the last volume in the list
'$profiles = (gci "path to vdisks" -recurse -Include .vhd,.vhdx).FullName
foreach ($prof in $profiles) {
"select vdisk file=`"$prof`"`r`nexpand vdisk maximum=40000`r`nattach vdisk" | diskpart
$vol = (("list vol" | diskpart | select-string "volume" | select -last 1) -split "\s+")[2]
"select vdisk file=`"$prof`"`r`nselect vol $vol`r`nextend" | diskpart
"select vdisk file=`"$prof`"`r`ndetach vdisk" | diskpart
}'