Support for managing distributed switches was initially introduced in PowerCLI 4.1. In PowerCLI 4.1.1, we extend this functionality by making changes to the following cmdlets:
Name
|
Description
|
Get-VirtualSwitch
|
Returns both standard and distributed switches. You can filter the retrieved switches by their type.
|
Get-VirtualPortGroup
|
Returns the virtual port groups of the specified standard and distributed switches.
|
Get-VMHost
|
You can retrieve the hosts that are connected to a specific distributed switch.
|
Get-VM
|
You can retrieve the virtual machines that are connected to a specific distributed switch.
|
Get-VMHostNetworkAdapter
|
You can retrieve the host network adapters that are connected to a specific distributed switch.
|
New-NetworkAdapter, Set-NetworkAdapter
|
You can attach network adapters to a specific Port Id of the distributed switch.
|
By using PowerCLI cmdlets, you can migrate virtual machines and hosts between distributed virtual switches, and also create various reports related to distributed switches.
Example:
To list all distributed switches available in the vCenter Server, you can just run the Get-VirtualSwitch cmdlet:
1 |
<strong><em>Get-VirtualSwitch -Distributed</em></strong> |
1 |
Name NumPorts Num Ports Mtu Key Notes<br /> Available<br />---- -------- ---------- --- --- -----<br />dvSwitch 132 1500 9d 2e 25 50 f4 63 6d 42-25 ... PowerCLI vDS<br /><br /> |
The port groups on the distributed switch are also easy to retrieve:
1 |
<strong><em>Get-VirtualSwitch -Name dvSwitch | Get-VirtualPortGroup</em></strong> |
1 |
Name Key VLanId PortBinding NumPorts<br />---- --- ------ ----------- --------<br />dvPortGroup dvportgroup-118 Static 128<br />dvSwitch-DVUplinks-116 dvportgroup-117 Static 4<br /><br /> |
If you need to get the hosts connected to the distributed switch, just filter them by using the Get-VMHost cmdlet:
1 |
<strong><em>Get-VMHost -DistributedSwitch dvSwitch</em></strong> |
1 |
Name ConnectionState PowerState Id CpuUsage CpuTotal Memory Memory<br /> Mhz Mhz UsageMB TotalMB<br />---- --------------- ---------- -- -------- -------- ------- -------<br />192.168.1.125 Connected PoweredOn ...t-63 101 3178 911 2047<br /><br /> |
Even more, you can check which host network adapters are connected to a specific distributed switch:
1 |
<strong><em>Get-VMHostNetworkAdapter -DistributedSwitch dvSwitch | select VMHost, Name, Mac, IP</em></strong> |
1 |
VMHost Name Mac IP<br />------ ---- --- --<br />192.168.1.125 vmnic1 00:50:56:94:5f:3b<br />192.168.1.125 vmk0 00:50:56:94:18:5c 192.168.1.125<br /><br /><br /> |
To check which virtual machines are part of a distributed switch network, use the DistributedSwitch parameter of the Get-VM cmdlet:
1 |
<strong><em>Get-VM -DistributedSwitch dvSwitch</em></strong> |
1 |
Name PowerState Num CPUs Memory (MB)<br />---- ---------- -------- -----------<br />Dvs_vm1 PoweredOn 1 4096<br /><br /> |