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
# Retrieves all port groups named "VM Network".
Get-VirtualPortgroup -Name "VM Network"
Step 2 : Run commands from the CRUD group
# Creates a virtual port group named VPortGroup on the virtual switch VSwitch.
$vswitch = New-VirtualSwitch -VMHost 10.23.114.234 -Name VSwitch $vportgroup = New-VirtualPortGroup -VirtualSwitch $vswitch -Name VPortGroup
# Creates a new virtual switch named VSwitch on the virtual machine host with IP address 10.23.112.36. 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 10.23.112.36 -Name VSwitch $vportgroup1 = New-VirtualPortGroup -VirtualSwitch $vswitch -Name VPortGroup1 $vportgroup2 = Set-VirtualPortGroup -VirtualPortGroup $vportgroup1 -VLanId 1
# 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 10.23.112.234 -Name VirtualSwitch $vportgroup = New-VirtualPortGroup -VirtualSwitch $vswitch -Name VPortGroup Remove-VirtualPortGroup -VirtualPortGroup $vportgroup