Reply to Message

View discussion in a popup

Replying to:
LucD
Leadership
Leadership

Afaik, there is indeed no cmdlet to combine those actions.

It does seem to be possible with the UpdateVirtualNIC API method.

The following snippet is for a vmkernel that is moved from one VDS porgroup to another one.
It should be similar for a VSS based VMKernel, just use the Portgroup property instead of the DistributedVirtualPort property.

$esxName = '<MyESx>'
$vmkName = 'vmkx'

$newPG = '<new-vdPG>'

$esx = Get-VMHost -Name $esxName
$pg = Get-VDPortgroup -Name $newPG

$netSys = Get-View -Id $esx.ExtensionData.ConfigManager.NetworkSystem

$spec = New-Object -type VMware.Vim.HostVirtualNicSpec
$spec.Ip = New-Object -TypeName VMware.Vim.HostIPConfig
$spec.IP.Dhcp = $true
$spec.DistributedVirtualPort = New-Object -TypeName VMware.Vim.DistributedVirtualSwitchPortConnection
$spec.DistributedVirtualPort.SwitchUuid = $pg.vdswitch.ExtensionData.Uuid
$spec.DistributedVirtualPort.PortgroupKey = $pg.ExtensionData.Key

$netSys.UpdateVirtualNic($vmkName, $spec)

 


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

Reply
0 Kudos