SurajRawat
Contributor
Contributor

Script for DVSwitch Configuration

Jump to solution

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

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership

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


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

View solution in original post

0 Kudos
2 Replies
LucD
Leadership
Leadership

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


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

0 Kudos