Thanks Luc
What I am trying to do is add 4 new disks to an existing 2008R2 VM
The VM already has 2 disks, C: drive and D: drive
Hard Disk 1 SCSI 0:0
Hard Disk 2 SCSI 0:1
I then want to add the following 4 disks, this is our standard for SQL servers
Hard Disk 3 SCSI 1:0 new ParaVirtual Controller 1Gb
Hard Disk 4 SCSI 2:0 new ParaVirtual Controller 2Gb
Hard Disk 5 SCSI 2:1 Controller above 3Gb
Hard Disk 6 SCSI 3:0 new ParaVirtual Controller 4Gb
The sizes are only to help identify the disks
Using the code pasted below, I seem to get the following config, plus an error when allocating the 3rd disk, the error being
I guess it is trying to add to the default original Controller on UnitNumber 1 which is already in use
How do I point it at SCSI 2:1? Is there a device.ControllerNumber parameter?
On completion I get
Hard Disk 3 SCSI 0:2 3Gb
Hard Disk 4 SCSI 1:0 1Gb correct, other than I would expect it to be Hard Disk 3
Hard Disk 5 SCSI 2:2 2Gb should have been SCSI 2:0, and Hard Disk 4
Hard Disk 6 SCSI 3:3 4Gb should have been SCSI 3:0
I am assuming the error isn’t helping with the Hard Disk numbering?
The code I am using is
$vm = Get-VM -Name $VM_Name
$hd = New-HardDisk -VM $vm -CapacityGB $R_Drive_Size
$ctrl = New-ScsiController -HardDisk $hd -Type Paravirtual
$hd = Get-HardDisk -VM $vm | Where {$_.Name -eq $hd.Name}
$spec = New-Object VMware.Vim.VirtualMachineConfigSpec
$spec.ChangeVersion = $vm.ExtensionData.Config.ChangeVersion
$spec.DeviceChange += New-Object VMware.Vim.VirtualDeviceConfigSpec
$spec.deviceChange[0].device = $hd.ExtensionData
$spec.deviceChange[0].device.UnitNumber = 0
$spec.deviceChange[0].operation = "edit"
$vm.ExtensionData.ReconfigVM($spec)
$vm = Get-VM -Name $VM_Name
$hd = New-HardDisk -VM $vm -CapacityGB $S_Drive_Size
$ctrl = New-ScsiController -HardDisk $hd -Type Paravirtual
$hd = Get-HardDisk -VM $vm | Where {$_.Name -eq $hd.Name}
$spec = New-Object VMware.Vim.VirtualMachineConfigSpec
$spec.ChangeVersion = $vm.ExtensionData.Config.ChangeVersion
$spec.DeviceChange += New-Object VMware.Vim.VirtualDeviceConfigSpec
$spec.deviceChange[0].device = $hd.ExtensionData
$spec.deviceChange[0].device.UnitNumber = 0
$spec.deviceChange[0].operation = "edit"
$vm.ExtensionData.ReconfigVM($spec)
$vm = Get-VM -Name $VM_Name
$hd = New-HardDisk -VM $vm -CapacityGB $T_Drive_Size
$hd = Get-HardDisk -VM $vm | Where {$_.Name -eq $hd.Name}
$spec = New-Object VMware.Vim.VirtualMachineConfigSpec
$spec.ChangeVersion = $vm.ExtensionData.Config.ChangeVersion
$spec.DeviceChange += New-Object VMware.Vim.VirtualDeviceConfigSpec
$spec.deviceChange[0].device = $hd.ExtensionData
$spec.deviceChange[0].device.UnitNumber = 1
$spec.deviceChange[0].operation = "edit"
$vm.ExtensionData.ReconfigVM($spec)
$vm = Get-VM -Name $VM_Name
$hd = New-HardDisk -VM $vm -CapacityGB $U_Drive_Size
$ctrl = New-ScsiController -HardDisk $hd -Type Paravirtual
$hd = Get-HardDisk -VM $vm | Where {$_.Name -eq $hd.Name}
$spec = New-Object VMware.Vim.VirtualMachineConfigSpec
$spec.ChangeVersion = $vm.ExtensionData.Config.ChangeVersion
$spec.DeviceChange += New-Object VMware.Vim.VirtualDeviceConfigSpec
$spec.deviceChange[0].device = $hd.ExtensionData
$spec.deviceChange[0].device.UnitNumber = 0
$spec.deviceChange[0].operation = "edit"
$vm.ExtensionData.ReconfigVM($spec)
Cheers
Jim