VMware Cloud Community
yan2013
Contributor
Contributor

How to limit Network VM by powercli

Hello,

     I would like to change many Virtual Machine Network Limit via Powercli/powershell. It's very easy in virtual console but not in powershell

i know how to see the limit by this command

     $vm=get-vm -vm "AZERTY"

     ($vm|get-networkadapter).ExtensionData.ResourceAllocation.limit

          or

     $vm.NetworkAdapters[0].ExtensionData.ResourceAllocation.Limit

but it's not possible to change limit by this method and the option doesn't exist with set-networkadapter or by use VMware.Vim.VirtualMachineConfigSPec

Can you help me please :-)))

Thank You

Yannick Lecaille

amicalement Yannick Lecaille
Reply
0 Kudos
1 Reply
yan2013
Contributor
Contributor

i've found (thank you support vmware)

$vmName = 'computername'

$nicName = 'Network adapter 1'

$limit = 800

$vm = Get-VM -Name $vmName

$nic = Get-NetworkAdapter -VM $vm -Name $nicName

$spec = New-Object VMware.Vim.VirtualMachineConfigSpec

$dev = New-Object VMware.Vim.VirtualDeviceConfigSpec

$dev.Operation = [VMware.Vim.VirtualDeviceConfigSpecOperation]::edit

$dev.Device = $nic.ExtensionData

$dev.Device.ResourceAllocation.Limit = $limit

$spec.DeviceChange += $dev

$vm.ExtensionData.ReconfigVM($spec)

amicalement Yannick Lecaille
Tags (1)