VMware Cloud Community
ccnk
Contributor
Contributor
Jump to solution

add esxi host to vDS

Hi,

 

I have a requirement we need to add esxi server to vDS switch, we have working cluster where esxi server is already part of vDS with old version 6.0.0 now we have created a new vDS 6.6.0. now we need to remove the esxi server form vDS with 6.0.0 and add to new vDS 6.6.0. we need to automate this with powercli. could you please help.

Requirement is : we need to remove the esxi from existing vDS and add to new vDS update the uplinks and create new management and other VMkernal ports.
thank you. 

Reply
0 Kudos
2 Solutions

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

You can use the Set-VMHostNetworkAdapter and point to a portgroup on the new VDS.


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

View solution in original post

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Can you try with

$pg = Get-VdPortgroup -Name 'vmotion-new'
Get-VMHost esxi.lab.com | 
Get-VMHostNetworkAdapter -VMKernel -Name vmk1 | 
Set-VMHostNetworkAdapter -PortGroup $pg


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

View solution in original post

Reply
0 Kudos
10 Replies
LucD
Leadership
Leadership
Jump to solution

What do you already have, and did you encounter any issues with your code?


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

Reply
0 Kudos
ccnk
Contributor
Contributor
Jump to solution

This is what i am trying and got stuck, below is the code.

Connect-VIServer Vcname.com
Get-VMHost -Name Esxi.lab.com | Get-VMHostNetworkAdapter -Physical -Name vmnic0 | Remove-VDSwitchPhysicalNetworkAdapter -Confirm:$false
Get-VDSwitch -Name "New-vds" | Add-VDSwitchVMHost -VMHost "Esxi.lab.com"
Add-VDSwitchVMHost -VDSwitch "New-vds" -VMHost Esxi.lab.com
$vmhostNetworkAdapter = Get-VMHost Esxi.lab.com | Get-VMHostNetworkAdapter -Physical -Name vmnic0
Get-VDSwitch "New-vds" | Add-VDSwitchPhysicalNetworkAdapter -VMHostPhysicalNic $vmhostNetworkAdapter

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

How did you get stuck?
Any errors?


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

Reply
0 Kudos
ccnk
Contributor
Contributor
Jump to solution

I am unable to figure out what cmdlets do i need to use next to migrate management vmkernal port and portgroup from current vDs to new vDs.

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

You can use the Set-VMHostNetworkAdapter and point to a portgroup on the new VDS.


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

Reply
0 Kudos
ccnk
Contributor
Contributor
Jump to solution

I am able to add vmk0 with below command, but when i using similar command for Vmotion vmkernal i am getting error message

working command for management vmkernal 

Get-VMHost esxi.lab.com | Get-VMHostNetworkAdapter -VMKernel -Name vmk0 | Set-VMHostNetworkAdapter -PortGroup "management-new "

not working for vmotion vmkernal adapter 

Get-VMHost esxi.lab.com | Get-VMHostNetworkAdapter -VMKernel -Name vmk1 | Set-VMHostNetworkAdapter -PortGroup "vmotion-new"

Set-VMHostNetworkAdapter : 5/4/2022 11:11:35 PM Set-VMHostNetworkAdapter Could not find DistributedPortGroup with name 'vmotion-new'.
At line:1 char:86
+ ... Name vmk1 | Set-VMHostNetworkAdapter -PortGroup "vmotion-new...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (vmotion-new:String) [Set-VMHostNetworkAdapter], VimException
+ FullyQualifiedErrorId : Core_ObnSelector_SelectObjectByNameCore_ObjectNotFound,VMware.VimAutomation.ViCore.Cmdlets.Commands.Host.SetVMHostNetworkAdapter

Set-VMHostNetworkAdapter : 5/4/2022 11:11:35 PM Set-VMHostNetworkAdapter Value cannot be found for the mandatory parameter PortGroup
At line:1 char:86
+ ... Name vmk1 | Set-VMHostNetworkAdapter -PortGroup "vmotion-new ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Set-VMHostNetworkAdapter], VimException
+ FullyQualifiedErrorId : Core_BaseCmdlet_UnknownError,VMware.VimAutomation.ViCore.Cmdlets.Commands.Host.SetVMHostNetworkAdapter

 

vmotion-new is on new vDS. could you please help further.

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Looks like that 'vmotion-new' portgroup is not found on the VDS


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

Reply
0 Kudos
ccnk
Contributor
Contributor
Jump to solution

Its there on the new vDS, i was able to move the NFS VMkernalport with same command but i am unable to move the Vmotion one . could you please test from your end if possible.

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Can you try with

$pg = Get-VdPortgroup -Name 'vmotion-new'
Get-VMHost esxi.lab.com | 
Get-VMHostNetworkAdapter -VMKernel -Name vmk1 | 
Set-VMHostNetworkAdapter -PortGroup $pg


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

Reply
0 Kudos
ccnk
Contributor
Contributor
Jump to solution

Thank you buddy it worked now.

Reply
0 Kudos