VMware Communities > Developer Community > VMware vSphere™ PowerCLI > Discussions

This Question is Answered

2 "helpful" answers available (6 pts)
2 Replies Last post: Jun 4, 2008 11:15 PM by crnielsen
Reply

Problem with New-Harddisk

Jun 3, 2008 1:01 PM

Click to view crnielsen's profile Enthusiast crnielsen 53 posts since
Dec 8, 2004

Hi

I am trying to create a new harddisk to my VM. When I execute the command I get an error.

PS C:\Program Files\VMware\Infrastructure\VIToolkitForWindows> get-vm "HORSE" | new-harddisk -capacitykb 10240
New-HardDisk : 03-06-2008 21:54:47 New-HardDisk No free LSI nodes
At line:1 char:32
+ get-vm "HORSE" | new-harddisk <<<< -capacitykb 10240
PS C:\Program Files\VMware\Infrastructure\VIToolkitForWindows>

It is a VM without a SCSI controller, an I guess it tells me that. Then my question is: How do I add a SCSI controller??

Regards

Claus

Reply Re: Problem with New-Harddisk Jun 4, 2008 12:12 PM
Click to view LucD's profile Virtuoso LucD 1,745 posts since
Oct 31, 2005
The function below adds a BusLogic SCSI controller to a guest.

The prerequisite for the function to work correctly is that there are no devices with the same "key" defined on the guest.
The function could be elaborated with a test that loops through the current devices and checks if the key is free.
Something like the functions I showed in Re: Changing Disk Persistence

function add-SCSIController {
  param($VMname)
 
  $vm = Get-View (Get-VM $VMname).ID
 
  $spec = New-Object VMware.Vim.VirtualMachineConfigSpec
  $spec.deviceChange = @()
  $spec.deviceChange += New-Object VMware.Vim.VirtualDeviceConfigSpec
 
  $spec.deviceChange[0].device = New-Object VMware.Vim.VirtualBusLogicController
  $spec.deviceChange[0].device.busNumber = 0
  $spec.deviceChange[0].device.ControllerKey = 100
  $spec.deviceChange[0].device.DeviceInfo = New-Object VMware.Vim.Description
  $spec.deviceChange[0].device.DeviceInfo.label = "SCSI Controller 0"
  $spec.deviceChange[0].device.DeviceInfo.summary = "BusLogic"
  $spec.deviceChange[0].device.hotAddRemove = $TRUE
  $spec.deviceChange[0].device.key = 1000
  $spec.deviceChange[0].device.scsiCtlrUnitNumber = 7
  $spec.deviceChange[0].device.sharedBus = "noSharing"
  $spec.deviceChange[0].operation = "add"
 
  $vm.ReconfigVM_Task($spec)
}
 
Add-SCSIController("HORSE")
 
Get-VM "HORSE" | New-HardDisk -CapacityKB 10240
Reply Re: Problem with New-Harddisk Jun 4, 2008 11:15 PM
in response to: LucD
Click to view crnielsen's profile Enthusiast crnielsen 53 posts since
Dec 8, 2004

That did the trick. Thanks for the nice script. (I modified it to add a LSI scsi adapter in no time)

Regards

Claus

Actions