New-VirtualSwitch Command | Vmware PowerCLI Reference

New-VirtualSwitch

This cmdlet creates a new virtual switch on the host that is specified by the VMHost parameter.

Syntax

New-VirtualSwitch
[ -Name ] < String >
-VMHost < VMHost >
[ [-NumPorts ] < Int32 > ]
[ [-Nic ] < PhysicalNic[] > ]
[ [-Mtu ] < Int32 > ]
[-ProgressAction < ActionPreference > ]
[-Server < VIServer[] > ]
[CommonParameters]

Parameters

Required Parameter Name Type Position Features Description
required
Name String 1
Specifies a name for the new virtual switch.
required
VMHost VMHost named
  • pipeline
  • wildcards
Specifies the host on which you want to create the new virtual switch.
optional NumPorts Int32 2
Specifies the virtual switch port number. The value is rounded to the closest exact power of two that is greater than the given number (for example, if the user specifies 67, this number is rounded to 128). Note that the port number displayed in the vSphere Client might differ from the value that you specified for the NumPorts parameter. Note: In ESX 5.5 or later, standard virtual switches are always elastic, so the NumPorts parameter is no longer applicable and its value is ignored.
optional Nic PhysicalNic[] 3
  • wildcards
Specifies the physical network interface cards you want to add to the Active NICs of the new virtual switch. This parameter accepts both objects and strings.
optional Mtu Int32 4
Specifies the maximum transmission unit (MTU) associated with the specified virtual switch (in bytes). The MTU value is always greater than 0.
optional ProgressAction ActionPreference named
optional Server VIServer[] named
  • wildcards
Specifies the vCenter Server systems on which you want to run the cmdlet. If no value is provided or $null value is passed to this parameter, the command runs on the default servers. For more information about default servers, see the description of Connect-VIServer.

Output

VMware.VimAutomation.ViCore.Types.V1.Host.Networking.VirtualSwitch

Examples

Example 1

$vswitch =  New-VirtualSwitch -VMHost 10.23.112.234 -Name VSwitch

Creates a new virtual switch named VSwitch on the virtual machine host with IP address 10.23.112.234.

Example 2

$network = Get-VMHostNetwork -VMHost 10.23.112.234

$phNic = $network.PhysicalNic[0].DeviceName

$vswitch = New-VirtualSwitch -VMHost 10.23.112.234 -Name VSwitch -Nic $phNic

Creates a new virtual switch named VSwitch on the virtual machine host with IP address 10.23.112.234 with a physical network adapter.

Example 3

Get-VMHost *.128 | New-VirtualSwitch -Name VSwitch -Nic vmnic5,vmnic6

Create a virtual switch named VSwitch with two physical network adapters - 'vmnic5' and 'vmnic6'. Note that the 'vmnic5' and 'vmnic6' adapters must not be assigned to other virtual switches.

Related Commands

VirtualSwitch

This cmdlet retrieves the virtual switches associated with a virtual machine host or used by a virtual machine.

This cmdlet creates a new virtual switch.

This cmdlet removes the specified virtual switches from their locations.

This cmdlet modifies the properties of the specified virtual switch.

VirtualSwitchPhysicalNetworkAdapter

This cmdlet adds a host physical NIC to a standard virtual switch.

This cmdlet removes the specified host physical NICs from the standard virtual switch.