< Back

Set-VirtualSwitch

Sun Jan 19, 2020 7:10 pm

NAME Set-VirtualSwitch



SYNOPSIS

This cmdlet modifies the properties of the specified virtual switch.





SYNTAX

Set-VirtualSwitch [-VirtualSwitch] <VirtualSwitch[]> [[-NumPorts] <Int32>] [[-Nic] <String[]>] [[-Mtu] <Int32>]

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





DESCRIPTION

This cmdlet modifies the properties of the specified virtual switch. The server rounds the value of the NumPorts

parameter up to the closest exact power of two, greater than the provided number. When updating NumPorts, the user

needs to restart the ESX/ESXi host for the change to take effect.





PARAMETERS

-Mtu <Int32>

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

value must be greater than 0.



Required? false

Position? 4

Default value None

Accept pipeline input? False

Accept wildcard characters? false



-Nic <String[]>

Specifies new network interface cards for the virtual switch. The old NICs are replaced by the specified ones.



Required? false

Position? 3

Default value None

Accept pipeline input? False

Accept wildcard characters? false



-NumPorts <Int32>

Specifies the VirtualSwitch port number. The value is rounded to the closest exact power of two, greater than

the provided number (for example, if the user specifies 67, this number is rounded to 128). The ESX host to

which the virtual switch belongs, must be restarted for the change to take effect. 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? 2

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



-VirtualSwitch <VirtualSwitch[]>

Specifies the virtual switch you want to configure.



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

Zero or more modified VirtualSwitch objects







NOTES





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 -Host 10.23.115.67 -Name VSwitch



Set-VirtualSwitch -VirtualSwitch $vswitch -MTU 500



Creates a new virtual switch named VSwitch on the virtual machine host on IP address 10.23.115.67. Then sets the

virtual switch MTU to 500.

-------------------------- Example 2 --------------------------



$vswitch = New-VirtualSwitch -VMHost 10.23.115.67



$networkAdapters = Get-VMHostNetworkAdapter -VMHost 10.23.115.67 -Physical



$phNic = $networkAdapters[0]



$vSwitch | Set-VirtualSwitch -Nic $phNic



Creates a new virtual switch named VSwitch on the virtual machine host on IP address 10.23.115.67. Then assigns to

it a network adapter.

-------------------------- Example 3 --------------------------



Get-VMHost *.128 | Get-VirtualSwitch | Select-Object -First 1 | Set-VirtualSwitch -Nic vmnic5



Add a physical network adapter named 'vmnic5' to the first switch of the host. Note that the 'vmnic5' adapter must

not be assigned to other virtual switches.



RELATED LINKS

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

Get-VirtualSwitch

New-VirtualSwitch

Remove-VirtualSwitch