VirtualSwitch Category | Vmware PowerCLI Reference

Virtual 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-VirtualSwitch cmdlet. See example below:

# Retrieves the virtual switch used by the virtual machine named VM.

Get-VirtualSwitch -VM VM

Step 2 : Run commands from the CRUD group

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

# Creates a new virtual switch named VSwitch on the virtual machine host with IP address 10.23.112.234.

$vswitch = New-VirtualSwitch -VMHost 10.23.112.234 -Name VSwitch
You can UPDATE objects by using Add-VirtualSwitchPhysicalNetworkAdapter cmdlet. See example below:

# Adds a VMHost physical network adapter to the specified distributed switch.

$myVMHostNetworkAdapter = Get-VMhost "MyVMHost" | Get-VMHostNetworkAdapter -Physical -Name vmnic2 Get-VirtualSwitch "MyVirtualSwitch" | Add-VirtualSwitchPhysicalNetworkAdapter -VMHostPhysicalNic $myVMHostNetworkAdapter
You can REMOVE objects by using Remove-VirtualSwitch cmdlet. See example below:

# Creates a new virtual switch named VirtualSwitch on the host with an IP address 10.23.122.145. Then removes the virtual switch.

$vswitch = New-VirtualSwitch -VMHost 10.23.122.145 -Name VirtualSwitch Remove-VirtualSwitch -VirtualSwitch $vswitch

Step 3: Explore More Related Commands:


Remove-VirtualSwitchPhysicalNetworkAdapter This cmdlet removes the specified host physical NICs from the standard virtual switch.
Set-VirtualSwitch This cmdlet modifies the properties of the specified virtual switch.