I am adding a drive to a new server and want it on a new SCSI controller. It adds the drive, but assigns it to the OS controller and not the new one it creates. Here is the sysntex I am using in the script. It is basically the same as the Command Reference Guide for adding a drive to a new SCSI Controller. I have it in an if statement. I am reading input from a CSV file and if the server being built doesnt need a second drive it scips it.
if ($driveD -ne "")
{
$disk1 = Get-VM $vmname | New-HardDisk -CapacityKB $driveD -StorageFormat $layoutD | New-ScsiController -Type ParaVirtual -Confirm:$false
}
Here is the error I get when I run the script.
New-ScsiController : 3/6/2012 7:58:28 AM New-ScsiController Value cannot be null.
Parameter name: array
At C:\Users\XXXXXXXX\Documents\PowerCli\Deploy\DeployFromTemplate.ps1:110 char:107
+ $disk1 = Get-VM $vmname | New-HardDisk -CapacityKB $driveD -StorageFormat $layoutD | New-ScsiController <<<< -Type
ParaVirtual -Confirm:$false
+ CategoryInfo : NotSpecified: (:) [New-ScsiController], VimException
+ FullyQualifiedErrorId : Core_BaseCmdlet_UnknownError,VMware.VimAutomation.ViCore.Cmdlets.Commands.VirtualDevice.NewScsiCon
troller
Line 110 is the $disk.
Attaching script
Are you using PowerCLI 5.0.1 ?
Get-PowerCLIVersion
Does the line work when you execute it from the PowerCLI prompt with values instead of variables ?
Get-VM AVM | New-HardDisk -CapacityKB 1024 -StorageFormat Thin |
New-ScsiController -Type ParaVirtual -Confirm:$false
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Yes I am running 5.0.1 PowerCLI. I am also runing VC 5.0 and ESXi 4.1
PowerCLI Version
----------------
VMware vSphere PowerCLI 5.0.1 build 581491
---------------
Snapin Versions
---------------
VMware AutoDeploy PowerCLI Component 5.0 build 544967
VMware ImageBuilder PowerCLI Component 5.0 build 544967
VMware License PowerCLI Component 5.0 build 544881
VMware vSphere PowerCLI Component 5.0 build 581435
I think I found the issue. My template has a second SCSI controller already for some reason. I have deleted it and I will deploy a new VM from it and try again. I think this will fix it because when I manually deleted all the extra disks and SCSI controllers after it was build the script worked and added the disks exactly the way it should have. I will let you know if it works now or not.
Strange, according to the Configuration Maximums for vSphere you should be able to have 4 SCSI controllers on a VM
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I think it was due to the fact that I had a scsi controller with no disks assigned so it would not let me add anymore.
After removing the SCSI controller with no disks from the template I have successfully deployed 6 servers and they all configured correctly.
Thanks for you help.
Was a configuration issue with the Template. With help I was able to figure that out.