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


$VM = Get-VM -Name "VMc2test"

for ($i=0;$i -le 63;$i++){

$vhdfilename = "vhdtest" + $i
New-VirtualDiskDrive -VM $VM -Dynamic -Filename $vhdfilename -sCSI -Size 4000 -Bus 0 -LUN $i
}

and to delete them

$vhds = @(Get-VirtualDiskDrive -VM vmc2test | where {$_.BusType -match "SCSI"})

foreach ($vhd in $vhds){

Remove-VirtualDiskDrive -VirtualDiskDrive $vhd

}

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