VirtualPortGroup Category | Vmware PowerCLI Reference

Virtual Port Group 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-VirtualPortGroup cmdlet. See example below:

# Retrieves all port groups named "VM Network".

Get-VirtualPortgroup -Name "VM Network"

Step 2 : Run commands from the CRUD group

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

# Creates a virtual port group named VPortGroup on the virtual switch VSwitch.

$vswitch = New-VirtualSwitch -VMHost -Name VSwitch $vportgroup = New-VirtualPortGroup -VirtualSwitch $vswitch -Name VPortGroup
You can UPDATE objects by using Set-VirtualPortGroup cmdlet. See example below:

# Creates a new virtual switch named VSwitch on the virtual machine host with IP address Creates a new virtual port group for the new switch named VPortGroup1. Sets the VLAN ID for the ports using the VPortGroup1 group.

$vswitch = New-VirtualSwitch -VMHost -Name VSwitch $vportgroup1 = New-VirtualPortGroup -VirtualSwitch $vswitch -Name VPortGroup1 $vportgroup2 = Set-VirtualPortGroup -VirtualPortGroup $vportgroup1 -VLanId 1
You can REMOVE objects by using Remove-VirtualPortGroup cmdlet. See example below:

# Creates a new virtual switch named VirtualSwitch and a virtual ports group VPortGroup for this switch. Then removes the virtual ports group.

$vswitch = New-VirtualSwitch -VMHost -Name VirtualSwitch $vportgroup = New-VirtualPortGroup -VirtualSwitch $vswitch -Name VPortGroup Remove-VirtualPortGroup -VirtualPortGroup $vportgroup