VMware Cloud Community
paul2ouy
Enthusiast
Enthusiast

PowerCLi

Guys,

Any help would be appreciated....

I have a SATA Controller and I am trying to add HD's via powercli, keep asking for SCSI controller type. The option I see for -controller is not "SATA Controller" .

Regards

Paul

Reply
0 Kudos
16 Replies
LucD
Leadership
Leadership

When you created the controller with the New-ScsiController cmdlet, which Type did you specify ?

Or do a Get-ScsiController and check the Type property.

But when you do a New-Harddisk to add the HD, the Controller parameter expects an object that is returned by New-ScsiController or Get-ScsiController.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
paul2ouy
Enthusiast
Enthusiast

LucD,

Maybe my first email was not well written, we have created a new SATA controller "SATA Controller 0"and we would like to add disk via powercli, the sata controller was added via the web gui and we have added a disk via the web gui. Issue is we would like t script this as we have multiple disks to add to the vm(s) so was wondering if this could be done via PowerCLi. Note this is the new type of disk that came available in 5.5 4 controllers 30 disks per controller.

Regards

Paul

Reply
0 Kudos
LucD
Leadership
Leadership

Can you include the output of the Get-ScsiController for that VM ?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
paul2ouy
Enthusiast
Enthusiast

Type                 BusSharingMode       UnitNumber

----                 --------------       ----------

VirtualLsiLogic      NoSharing                     3

VirtualLsiLogic      NoSharing                     4

Note this is only showing the 2 disk for get-ScsciController, Hard disk 4 is for the Sata controller 0 -the OS is Oracle Solaris 11 (64-bit)

Regards

Paul

VM setting below

pastedImage_0.png

Reply
0 Kudos
LucD
Leadership
Leadership

Ok, now I'm with you.

No, that type of controller is not supported in the current PowerCLI version.

You will have to revert to the API method ReconfigVM I'm afraid.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
paul2ouy
Enthusiast
Enthusiast

LucD,

Thanks buddy.... will say hello at VMworld Vegas if your there.

Regards

Paul

Reply
0 Kudos
LucD
Leadership
Leadership

Will do, let me know if you need a sample script for working with the SATA controller


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
paul2ouy
Enthusiast
Enthusiast

LucD,

Possible to get a sample script for working with the SATA controller... please

Regards

Paul

Reply
0 Kudos
LucD
Leadership
Leadership

Sure, try something like this

$vmName = 'MyVM'

$vm = Get-VM -Name $vmName

$spec = New-Object -TypeName VMware.Vim.VirtualMachineConfigSpec

$spec.ChangeVersion = $vm.ExtensionData.Config.ChangeVersion

$devConfig = New-Object -TypeName VMware.Vim.VirtualDeviceConfigSpec

$dev = New-Object -TypeName VMware.Vim.VirtualAHCIController

$info = New-Object -TypeName VMware.Vim.Description

$info.Label = 'SATA controller 1'

$info.Summary = 'AHCI'

$dev.DeviceInfo = $info

$dev.busNumber = 1

$devConfig.Device = $dev

$devConfig.operation = 'add'

$spec.DeviceChange += $devConfig

$vm.ExtensionData.ReconfigVM($spec)


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
paul2ouy
Enthusiast
Enthusiast

LucD,

Thank you for your help really appreciate that.

Regards

Paul

Reply
0 Kudos
markelios2
Contributor
Contributor

Hello all,

I would like to remove the SATA controller and change cd to use IDE controller instead SATA, but I don't figure it out.

Can you help me?

Thank you.

Reply
0 Kudos
LucD
Leadership
Leadership

Can you perhaps show how the devices are currently configured?

Something like this would help.

vm.png


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
markelios2
Contributor
Contributor

Of course,

here it is:

Reply
0 Kudos
markelios2
Contributor
Contributor

We did it, thank you.

It is a two step reconfiguration:

$vm = get-vm -name "YOUR_VM_NAME"

$spec = New-Object -TypeName VMware.Vim.VirtualMachineConfigSpec

$spec.ChangeVersion = $vm.ExtensionData.Config.ChangeVersion

$devConfig = New-Object -TypeName VMware.Vim.VirtualDeviceConfigSpec

$devConfig.Device = ($vm.ExtensionData.Config.Hardware.Device | where {$_.DeviceInfo.Label -imatch "CD"})

$devConfig.Device.Controllerkey = 200

$devConfig.operation = 'edit'

$spec.DeviceChange += $devConfig

$vm.ExtensionData.ReconfigVM($spec)

$vm = get-vm -name $vm.name

$spec = New-Object -TypeName VMware.Vim.VirtualMachineConfigSpec

$spec.ChangeVersion = $vm.ExtensionData.Config.ChangeVersion

$devConfig = New-Object -TypeName VMware.Vim.VirtualDeviceConfigSpec

$devConfig.Device = ($vm.ExtensionData.Config.Hardware.Device | where {$_.DeviceInfo.Label -imatch "SATA Controller"})

$devConfig.operation = 'remove'

$spec.DeviceChange += $devConfig

$vm.ExtensionData.ReconfigVM($spec)

Reply
0 Kudos
daphnissov
Immortal
Immortal

Hey LucD​, can you please provide a small code example that illustrates how to add any N number of new hard disks to an SATA controller, building on the fine example you posted here? It would be much appreciated for some tests I'm running to help another user. Thanks very much for your invaluable contributions.

Reply
0 Kudos
daphnissov
Immortal
Immortal

Not having much luck being able to add disks to this new SATA controller. I certainly wish the New-HardDisk cmdlet worked with SATA as well as SCSI controllers, but alas they do not.

Reply
0 Kudos