VMware Cloud Community
jvm2016
Hot Shot
Hot Shot
Jump to solution

vm_methods_powercli

Reply
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

You can only get the number of parameters and the type of each parameter that way.
The actual explanation of what the method does and the description and content of the parameters is only available in the API Reference afaik.


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

View solution in original post

Reply
0 Kudos
13 Replies
LucD
Leadership
Leadership
Jump to solution

You can only get the number of parameters and the type of each parameter that way.
The actual explanation of what the method does and the description and content of the parameters is only available in the API Reference afaik.


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

Reply
0 Kudos
jvm2016
Hot Shot
Hot Shot
Jump to solution

i am trying to see description of the following method

pastedImage_0.png

if yu can suggest the right place to get this as i did not find in the api expolrer i posted earlier.

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

You have to use the latest version of the API Reference.

See ApplyEVCModeVM_Task


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

Reply
0 Kudos
jvm2016
Hot Shot
Hot Shot
Jump to solution

thnaks Luc ,

below is what i got .i want to use this as reference example to create other methods .

pastedImage_0.png

if i compare  these three parametrs (_this,mask,completemasks)correspond to $vm ,$featuremasks and $true.

pastedImage_1.png

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

In this method the $this refers to $vm.ExtensionData, the VirtualMachine object.


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

Reply
0 Kudos
jvm2016
Hot Shot
Hot Shot
Jump to solution

if you could help me creating a similar task for adding disk_task in this post ..

this has only one datastore and vm has only one harddisk.

below is what i intend to perform based on the attach disk_method .

however i find this task little confusing as it does not ask for the size of the harddisk .

pastedImage_0.png

Reply
0 Kudos
jvm2016
Hot Shot
Hot Shot
Jump to solution

i think i need to use reconfigure vm task for adding new hard disk to vm .

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Not necessarily.

If your VM is at HW version vmx-13 or higher and you just want to connect 1 existing harddisk to the  VM, then you can use the AttachDisk method.

Do you want an example for AttachDisk?


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

Reply
0 Kudos
jvm2016
Hot Shot
Hot Shot
Jump to solution

actually i need example of adding new disk to vm using methods available in vm.extensiondata.

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

This is what I think is currently the minimum settings to add a VMDK to a VM.

There is 1 known flaw in there.

While calculating the next UnitNumber, the code doesn't take into account the maximum number of devices that can be connected to a controller.

$vmName = 'MyVM'

$dsName = 'MyDS'


$vm = Get-VM -Name $vmName

$ds = Get-Datastore -Name $dsName


$spec = New-Object VMware.Vim.VirtualMachineConfigSpec


$devSpec = New-Object VMware.Vim.VirtualDeviceConfigSpec

$devSpec.Operation = [vmware.vim.VirtualDeviceConfigSpecOperation]::add

$devSpec.FileOperation = [vmware.vim.VirtualDeviceConfigSpecFileOperation]::create


$dev = New-Object VMware.Vim.VirtualDisk

$dev.CapacityInKB = 1GB/1KB

$dev.Key = -100

$dev.ControllerKey = (Get-ScsiController -VM $vm -Name 'SCSI controller 0').ExtensionData.Key

$dev.UnitNumber = ((Get-HardDisk -VM $vm | where{$_.ExtensionData.ControllerKey -eq $dev.ControllerKey}).ExtensionData.UnitNumber |

    Measure-Object -Maximum).Maximum + 1


$devBack = New-Object VMware.vim.VirtualDiskFlatVer2BackingInfo

$devBack.DiskMode = [VMware.Vim.VirtualDiskMode]::persistent

$devBack.ThinProvisioned = $true

$devBack.Datastore = $ds.ExtensionData.MoRef

$devBack.FileName = "[$dsName]"


$dev.Backing = $devBack


$devSpec.Device = $dev


$spec.DeviceChange += $devSpec


$vm.ExtensionData.ReconfigVM($spec)


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

Reply
0 Kudos
jvm2016
Hot Shot
Hot Shot
Jump to solution

Thanks  Luc,

unlike other methods this is little not self explanatory in the document .

is there any other resource other than for spec

https://vdc-repo.vmware.com/vmwb-repository/dcr-public/790263bc-bd30-48f1-af12-ed36055d718b/e5f17bfc...

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Besides the Reference, there are also some User Guides.
They are written for specific frameworks, but you can still pick up quite a bit from those.
This for example for the .NET framework.

For the basics, there is also Steve Jin's VMware VI and vSphere DSK book.
It is written for Java and covers a rather old vSphere version, but this is a good study guide (provided you can at least read the Java examples).

And besides those, it's a matter of practising and looking at examples from others.


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

Reply
0 Kudos
jvm2016
Hot Shot
Hot Shot
Jump to solution

thanks

Reply
0 Kudos