< Back

New-VirtualSwitch

Sun Jan 19, 2020 7:01 pm

NAME New-VirtualSwitch



SYNOPSIS

This cmdlet creates a new virtual switch.





SYNTAX

New-VirtualSwitch [-VMHost] <VMHost> [-Name] <String> [[-NumPorts] <Int32>] [[-Nic] <PhysicalNic[]>] [[-Mtu]

<Int32>] [-Server <VIServer[]>] [-Confirm] [-WhatIf] [<CommonParameters>]





DESCRIPTION

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





PARAMETERS

-Mtu <Int32>

Specifies the maximum transmission unit (MTU) associated with the specified virtual switch (in bytes). The MTU

value is always greater than 0.



Required? false

Position? 5

Default value None

Accept pipeline input? False

Accept wildcard characters? false



-Name <String>

Specifies a name for the new virtual switch.



Required? true

Position? 2

Default value None

Accept pipeline input? False

Accept wildcard characters? false



-Nic <PhysicalNic[]>

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.



Required? false

Position? 4

Default value None

Accept pipeline input? False

Accept wildcard characters? true



-NumPorts <Int32>

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.



Required? false

Position? 3

Default value None

Accept pipeline input? False

Accept wildcard characters? false



-Server <VIServer[]>

Specifies the vCenter Server systems on which you want to run the cmdlet. If no 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.



Required? false

Position? named

Default value None

Accept pipeline input? False

Accept wildcard characters? true



-VMHost <VMHost>

Specifies the host on which you want to create the new virtual switch.



Required? true

Position? 1

Default value None

Accept pipeline input? True (ByValue)

Accept wildcard characters? true



-Confirm [<SwitchParameter>]

If the value is $true, indicates that the cmdlet asks for confirmation before running. If the value is $false,

the cmdlet runs without asking for user confirmation.



Required? false

Position? named

Default value $true

Accept pipeline input? False

Accept wildcard characters? false



-WhatIf [<SwitchParameter>]

Indicates that the cmdlet is run only to display the changes that would be made and actually no objects are

modified.



Required? false

Position? named

Default value False

Accept pipeline input? False

Accept wildcard characters? false



<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,

ErrorAction, ErrorVariable, WarningAction, WarningVariable,

OutBuffer, PipelineVariable, and OutVariable. For more information, see

about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).



INPUTS



OUTPUTS

The newly created VirtualSwitch object







NOTES





NumPorts are at least as many as the user specified. (The server rounds it up to the closest exact power of

two, greater than the given number) The MTU field is only available on VPX 2.5 and ESX 3.5. For older VPX

versions, this field is expected to be null.



-------------------------- 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 LINKS

Online Version: https://code.vmware.com/doc/preview?id= ... witch.html

Get-VirtualSwitch