VDSwitch Category | Vmware PowerCLI Reference

VD Switch Category

Cmdlets are usually implemented around resource operations. The four basic operations are CREATE, READ, UPDATE and DELETE. This set of operations is known as CRUD. Most of the cmdlets support CRUD which are respectively cmdlets that start with the New/Get/Set/Remove cmdlet verbs but they also may have additional operations

Step 1: Retrieve a object by running a Get command

You can READ objects by using Get-VDSwitch cmdlet. See example below:

# Retrieves all vSphere distributed switches in the specified datacenter.

Get-Datacenter -Name MyDatacenter | Get-VDSwitch

Step 2 : Run commands from the CRUD group

You can CREATE objects by using New-VDSwitch cmdlet. See example below:

# Creates a new vSphere distributed switch with the specified name, version, maximum number of ports, and link discovery protocol settings in the specified datacenter.

$myDatacenter = Get-Datacenter -Name "MyDatacenter" New-VDSwitch -Name "MyVDSwitch" -Location $myDatacenter -LinkDiscoveryProtocol "LLDP" -LinkDiscoveryProtocolOperation "Listen" -MaxPorts 256 -Version "5.0.0"
You can UPDATE objects by using Add-VDSwitchPhysicalNetworkAdapter cmdlet. See example below:

# Retrieves the specified physical network adapter from the specified host and adds it to the specified vSphere distributed switch.

$vmhostNetworkAdapter = Get-VMHost "MyVMHost" | Get-VMHostNetworkAdapter -Physical -Name vmnic2 Get-VDSwitch "MyVDSwitch" | Add-VDSwitchPhysicalNetworkAdapter -VMHostPhysicalNic $vmhostNetworkAdapter
You can REMOVE objects by using Remove-VDSwitch cmdlet. See example below:

# Removes the specified vSphere distributed switch.

Get-VDSwitch -Name MyVDSwitch | Remove-VDSwitch

Step 3: Explore More Related Commands:


Add-VDSwitchVMHost This cmdlet adds hosts to the specified vSphere distributed switch.
Export-VDSwitch This cmdlet exports the configuration of a specified vSphere distributed switch to a .zip file.
Get-VDSwitchPrivateVlan This cmdlet retrieves the private VLAN configuration entries of a vSphere distributed switch.
New-VDSwitchPrivateVlan This cmdlet creates private VLAN configuration entries on a vSphere distributed switch.
Remove-VDSwitchPhysicalNetworkAdapter This cmdlet removes host physical network adapters from the vSphere distributed switches they are connected to.
Remove-VDSwitchPrivateVlan This cmdlet removes private VLAN configuration entries from vSphere distributed switches.
Remove-VDSwitchVMHost This cmdlet removes hosts from the specified vSphere distributed switches.
Set-VDSwitch This cmdlet modifies the configuration of vSphere distributed switches.