A vSphere
distributed switch lets you handle networking traffic for all associated hosts
in a data center. After you create a new vSphere distributed switch in
PowerCLI, you can add hosts and connect virtual machines to it.
Prerequisites
Verify that you are connected
to a
vCenter
Server
system.
Procedure
-
Get the data center
where you want to create the vSphere distributed switch.
$myDatacenter = Get-Datacenter -Name "MyDatacenter"
-
Get all hosts in your
data center.
$vmHosts = $myDatacenter | Get-VMHost
-
Create a new vSphere
distributed switch.
$myVDSwitch = New-VDSwitch -Name "MyVDSwitch" -Location $myDatacenter
The
distributed switch is created with no port groups.
-
Add the hosts in your
data center to the distributed switch.
Add-VDSwitchVMHost -VDSwitch $myVDSwitch -VMHost $vmHosts
-
Get a physical network
adapter from your hosts.
$hostsPhysicalNic = $vmHosts | Get-VMHostNetworkAdapter -Name "vmnic2"
-
Add the physical network
adapter to the distributed switch that you created.
Add-VDSwitchPhysicalNetworkAdapter -VMHostNetworkAdapter $hostsPhysicalNic -DistributedSwitch $myVDSwitch
-
Create a new distributed
port group with 1000 ports and add it to the distributed switch.
$myVDPortGroup = New-VDPortgroup -Name "MyVMsPortGroup" -VDSwitch $myVDSwitch -NumPorts 1000
-
Connect all virtual
machines running on the hosts in your data center to the distributed port
group.
$vmHosts | Get-VM | Get-NetworkAdapter | Set-NetworkAdapter -PortGroup $myVDPortGroup
What to do next
Adjust the settings of the
distributed switch. See
Configure a Distributed Switch.