Automation

 View Only
  • 1.  Script for DVSwitch Configuration

    Posted May 11, 2016 04:28 AM

    Hello,

    Does anyone have a script to get the VDS information on the host level as to which nic is connected to which uplink ?

    Also to remove any portgroups created in the VDS switch for the host and then to recreate the portgroups as they were after connecting the host to a diff vCenter ?

    Also any script to copy the resource pools across VCenter ?

    Thanks,

    Suraj Rawat



  • 2.  RE: Script for DVSwitch Configuration



  • 3.  RE: Script for DVSwitch Configuration
    Best Answer

    Posted May 11, 2016 10:16 AM

    The following script will export the VDS information for the uplinks, the port they are on and which pNIC is used per ESXi node.

    $report = foreach($dvSw in Get-VDSwitch){

      foreach($esx in (Get-View -id $dvSw.ExtensionData.Summary.HostMember)){

        $proxy = $esx.Config.Network.ProxySwitch | where{$_.DvsUuid -eq $dvSw.ExtensionData.Uuid}

        $pnicTab = @{}

        $proxy.Spec.Backing.PnicSpec | %{

          $pnicTab.Add($_.UplinkPortKey,$_.PnicDevice)

        }

        $proxy.UplinkPort |

        Select @{N='vdSwitch';E={$dvSw.Name}},

          @{N='VMHost';E={$esx.Name}},

          @{N='vNIC';E={$pnicTab[$_.Key]}},

          @{N='Uplink';E={$_.Value}},

          @{N='Port';E={$_.Key}}

      }

    }

    $report | Export-Csv C:\dvSw-Uplink.csv -NoTypeInformation -UseCulture



  • 4.  RE: Script for DVSwitch Configuration

    Posted Nov 28, 2023 10:10 AM

    Hi,

    Thanks for this script, but i need to add the MAC of the vmnic for each line.

    i tried adding this line but it keeps giving empty result

    @{N='Mac';E={Get-VMHostNetworkAdapter -VMHost $(Get-VMHost -name $esx.Name)| Where-Object {$_.Name -eq $pnicTab[$_.Key]} |select Mac}},

    what am i missing?

    thanks

    Mordechai