Playing around with Powershell and SCVMM 2012 beta and Hyper-V R2

Hi

Have been playing a little with powershell and SCVMM2012 and with these simple lines i add 64 SCSI vhd drives á 4 GB each and then delete them all while the VM is running

</p>
<p>$VM = Get-VM -Name "VMc2test"</p>
<p>for ($i=0;$i -le 63;$i++){</p>
<p>$vhdfilename = "vhdtest" + $i<br />
New-VirtualDiskDrive -VM $VM -Dynamic -Filename $vhdfilename -sCSI -Size 4000 -Bus 0 -LUN $i<br />
}</p>
<p>

and to delete them

<br />
$vhds = @(Get-VirtualDiskDrive -VM vmc2test | where {$_.BusType -match "SCSI"})</p>
<p>foreach ($vhd in $vhds){</p>
<p>Remove-VirtualDiskDrive -VirtualDiskDrive $vhd</p>
<p>}</p>
<p>

and why did i select the ones that had SCSI in the remove part, well the system vhd where the OS resides is on the IDE controller so i can safely assume that the OS will still be accessible, as some of you already know in Hyper-V the boot volume must reside on a IDE controller for the VM to boot.

Leave a comment

name*

email* (not published)

website