VMware

This Question is Answered

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

Problem with New-Harddisk posted: Jun 3, 2008 1:01 PM

Click to view crnielsen's profile Enthusiast 54 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

Re: Problem with New-Harddisk

1. Jun 4, 2008 12:12 PM in response to: crnielsen
Click to view LucD's profile Champion 2,435 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

VMware Developer

SDKs, APIs, Videos, Learn and much more in the Developer community.

Learn More

Developer Sample Code

Increase your developer productivity with VMware API sample code.

Learn More

VMworld Sessions & Labs

Online access to the latest VMworld Sessions & Labs and online services.

Learn more

Purchase PSO Credits Online

Purchase credits to redeem training and consulting services online.

Buy Now

Community Hardware Software

View reported configurations or report your own.

Learn More

VMware vSphere

Come witness the next giant leap in virtualization.

Register Today

Communities