Home > Blogs > VMware PowerCLI Blog > Tag Archives: Distributed switch

Tag Archives: Distributed switch

Using PowerCLI for Distributed Switch Management

We’re excited to release another video in the series on PowerCLI tips and tricks! This time we’re covering how to use PowerCLI for distributed switch management.

This video shows how to perform the following tasks easily:

  • Creating a vSphere Distributed Switch
  • Adding Hosts to the Created vSphere Distributed Switch
  • Creating Distributed Port Groups
  • Creating a VMKernel NIC with vMotion Enabled
  • Creating a VMKernel NIC with Fault Tolerance Enabled
  • Backing Up a vSphere Distributed Switch Configuration
  • Restoring a vSphere Distributed Switch Configuration

Watch the Video

Other videos in this series are available below. If you haven’t seen them yet, I highly recommend them. They are all quick, easy to learn and easy to reproduce in your own environment.

Enhanced Support for Distributed Switches in PowerCLI 4.1.1

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:

The port groups on the distributed switch are also easy to retrieve:

If you need to get the hosts connected to the distributed switch, just filter them by using the Get-VMHost cmdlet:

Even more, you can check which host network adapters are connected to a specific distributed switch:

To check which virtual machines are part of a distributed switch network, use the DistributedSwitch parameter of the Get-VM cmdlet: