Automation

 View Only
  • 1.  add esxi host to vDS

    Posted May 04, 2022 10:34 AM

    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. 



  • 2.  RE: add esxi host to vDS

    Posted May 04, 2022 11:35 AM

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



  • 3.  RE: add esxi host to vDS

    Posted May 04, 2022 01:16 PM

    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



  • 4.  RE: add esxi host to vDS

    Posted May 04, 2022 01:56 PM

    How did you get stuck?
    Any errors?



  • 5.  RE: add esxi host to vDS

    Posted May 04, 2022 02:12 PM

    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.



  • 6.  RE: add esxi host to vDS
    Best Answer

    Posted May 04, 2022 02:18 PM

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



  • 7.  RE: add esxi host to vDS

    Posted May 05, 2022 05:20 AM

    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.



  • 8.  RE: add esxi host to vDS

    Posted May 05, 2022 07:44 AM

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



  • 9.  RE: add esxi host to vDS

    Posted May 05, 2022 08:57 AM

    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.



  • 10.  RE: add esxi host to vDS
    Best Answer

    Posted May 05, 2022 09:15 AM

    Can you try with

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


  • 11.  RE: add esxi host to vDS

    Posted May 05, 2022 10:33 AM

    Thank you buddy it worked now.