powershellscripts.com

Tutorials  PowerShell Cmdlet Help for New-VirtualSwitch



NAME
New-VirtualSwitch

SYNOPSIS
Creates a new virtual switch.

SYNTAX
New-VirtualSwitch [-VMHost] [-Name] [[-NumPorts] ] [[-Nic] ] [[-Mtu] >] [-Server ] [-WhatIf] [-Confirm] []


DESCRIPTION
Creates a new virtual switch on the host that is specified by the VMHost parameter.


PARAMETERS
-VMHost
Specify the host on which you want to create the new virtual switch.

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

-Name
Specify a name for the new virtual switch.

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

-NumPorts
Specify the virtual switch port number. The value is rounded to the closest exact power of two that is bigger t
han the given number (for example, if the user specifies 67, this number is rounded to 128). The value range is
between 1 and 1024. Note that the port number displayed in the vSphere Client might differ from the value that
you specified for the NumPorts parameter.

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

-Nic
Specify 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
Accept pipeline input? false
Accept wildcard characters? true

-Mtu
Specify the maximum transmission unit (MTU) associated with the specified virtual switch (in bytes). The MTU va
lue is always bigger than 0. This parameter is supported only on vCenter 2.5, ESX 3.5, and later..

Required? false
Position? 5
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


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)
MTU field is only available on vCenter 2.5 and ESX 3.5. For older API versions this field is expected to be nul
l.

-------------- Example 1 --------------

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

C:\PS>$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 physica
l network adapter.





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

C:\PS>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 'vm
nic5' and 'vmnic6' adapters must not be assigned to other virtual switches.






RELATED LINKS
Online version: http://www.vmware.com/support/developer/PowerCLI/PowerCLI501/html/New-VirtualSwitch.html
Get-VirtualSwitch