Automation

 View Only
  • 1.  Refresh of vmk adapters in dvSwitches

    Posted Dec 20, 2017 11:09 AM

    Hello I have a simple script here. You know that when a ESXi attached to dvSwitch is detached from VC and attached again it will show an "out of sync" message. That is fixed by going to web client  then dvswitch and Refresh the management adapters. Will that script do that job? unfortunately I cannot avail of a test env till January, due to shortage of HW. Many thanks!



  • 2.  RE: Refresh of vmk adapters in dvSwitches

    Posted Dec 20, 2017 11:42 AM

    That script looks like a migration to VDS script.

    I guess you need to use the RectifyDvsOnHost method to programmatically run the sync.



  • 3.  RE: Refresh of vmk adapters in dvSwitches

    Posted Dec 20, 2017 12:51 PM

    Thanks Luc, I looked at that page but it reports no examples, and if I run

    $vds = Get-VDSwitch myDVS

    on the variable I don't see that method. Could you please provide me with a simple code to refresh a dvswitch management adapter? or a refresh of such info on a Cluster level? whichever is fine..  I also googled and found nothing on that.. Thanks

    I'm planning a more complex script but this piece would be an import part..



  • 4.  RE: Refresh of vmk adapters in dvSwitches
    Best Answer

    Posted Dec 20, 2017 02:05 PM

    That is an API method, and you have to go via the ServiceInstance.

    As argument you pass the MoRef of the ESXi nodes where the Sync should run (the script below uses all ESXi nodes connected to the VDS)

    Try like this

    $vdsName = 'MyVDS'

    $vds = Get-VDSwitch -Name $vdsName

    $si = Get-View ServiceInstance

    $vdsMgr = Get-View -Id $si.Content.DvSwitchManager

    $esx = Get-VMHost -DistributedSwitch $vds | %{$_.ExtensionData.MoRef}

    $vdsMgr.RectifyDvsOnHost($esx)



  • 5.  RE: Refresh of vmk adapters in dvSwitches

    Posted Dec 20, 2017 03:24 PM

    Thanks, another lesson learnt.