powershellscripts.com

Tutorials  PowerShell Cmdlet Help for Set-VirtualSwitch



NAME
Set-VirtualSwitch

SYNOPSIS
Changes the properties of the specified virtual switch.

SYNTAX
Set-VirtualSwitch [-VirtualSwitch] [[-NumPorts] ] [[-Nic] ] [[-Mtu] ] [-S
erver ] [-WhatIf] [-Confirm] []


DESCRIPTION
Changes 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 given number. When updating NumPorts, the user needs to restart
the ESX host for the change to take effect.


PARAMETERS
-VirtualSwitch
Specify the virtual switch you want to configure.

Required? true
Position? 1
Default value
Accept pipeline input? true (ByValue)
Accept wildcard characters? true

-NumPorts
Specify the VirtualSwitch port number. The value is rounded to the closest exact power of two, greater than the
given number (for example, if the user specifies 67, this number is rounded to 128). The value range is betwee
n 1 and 1024. The ESX host the virtual switch belongs to, 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 Nu
mPorts parameter.

Required? false
Position? 2
Default value
Accept pipeline input? false
Accept wildcard characters? false

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

Required? false
Position? 3
Default value
Accept pipeline input? false
Accept wildcard characters? false

-Mtu
Specify the maximum transmission unit (MTU) associated with the specified virtual switch (in bytes). The MTU va
lue must be greater than 0. This parameter is valid only on VPX 2.5.

Required? false
Position? 4
Default value
Accept pipeline input? false
Accept wildcard characters? false

-Server
Specify the vSphere servers on which you want to run the cmdlet. If no value is given to this parameter, the co
mmand runs on the default servers. For more information about default servers, see the description of Connect-V
IServer.

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? true

-WhatIf
Indicate that the cmdlet is run only to display the changes that would be made and actually no objects are modi
fied.

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false

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


This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

INPUTS



OUTPUTS
VirtualSwitch


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

C:\PS>$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 vi
rtual switch MTU to 500.





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

C:\PS>$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 --------------

C:\PS>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: http://www.vmware.com/support/developer/PowerCLI/PowerCLI501/html/Set-VirtualSwitch.html
Get-VirtualSwitch
New-VirtualSwitch
Remove-VirtualSwitch