< Back

Get-VirtualPortGroup

Sun Jan 19, 2020 6:54 pm

NAME Get-VirtualPortGroup



SYNOPSIS

This cmdlet retrieves the available port groups of hosts, virtual machines, and virtual switches.





SYNTAX

Get-VirtualPortGroup [[-VMHost] <VMHost[]>] [-Datacenter <Datacenter[]>] [-Distributed] [-Name <String[]>]

[-Server <VIServer[]>] [-Standard] [-Tag <Tag[]>] [-VirtualSwitch <VirtualSwitchBase[]>] [-VM <VirtualMachine[]>]

[<CommonParameters>]



Get-VirtualPortGroup -Id <String[]> [-Server <VIServer[]>] [<CommonParameters>]



Get-VirtualPortGroup -RelatedObject <VirtualPortGroupRelatedObjectBase[]> [<CommonParameters>]





DESCRIPTION

This cmdlet retrieves the available port groups of hosts, virtual machines, and virtual switches. To specify a

server different from the default one, use the Server parameter.





PARAMETERS

-Datacenter <Datacenter[]>

Filters the port groups of the virtual switches connected to hosts in the specified datacenters.



Required? false

Position? named

Default value None

Accept pipeline input? True (ByValue)

Accept wildcard characters? true



-Distributed [<SwitchParameter>]

Indicates that you want to retrieve the port groups for DistributedSwitch objects. This parameter is obsolete.

To retrieve distributed port groups, use the Get-VDPortgroup cmdlet instead.



Required? false

Position? named

Default value False

Accept pipeline input? False

Accept wildcard characters? false



-Id <String[]>

Specifies the IDs of the port groups you want to retrieve.



Note: When a list of values is specified for the Id parameter, the returned objects would have an ID that

matches exactly one of the string values in that list.



Required? true

Position? named

Default value None

Accept pipeline input? False

Accept wildcard characters? true



-Name <String[]>

Specifies the names of the port groups you want to retrieve.



Required? false

Position? named

Default value None

Accept pipeline input? False

Accept wildcard characters? true



-RelatedObject <VirtualPortGroupRelatedObjectBase[]>

Specifies objects to retrieve one or more VirtualPortGroup objects that are related to them. This parameter

accepts vCloud NetworkPool, vCloud ExternalNetwork, and vCloud OrgNetwork objects.



Note: In vCloud Director 5.1 environments, you cannot retrieve a distributed port group from an organization

network backed by the distributed port group.



Required? true

Position? named

Default value None

Accept pipeline input? True (ByValue)

Accept wildcard characters? false



-Server <VIServer[]>

Specifies the vCenter Server systems on which you want to run the cmdlet. If no value is passed to this

parameter, the command runs on the default servers. For more information about default servers, see the

description of Connect-VIServer.



Required? false

Position? named

Default value None

Accept pipeline input? False

Accept wildcard characters? true



-Standard [<SwitchParameter>]

Indicates that you want to retrieve the port groups for VirtualSwitch objects.



Required? false

Position? named

Default value False

Accept pipeline input? False

Accept wildcard characters? false



-Tag <Tag[]>

Returns only the virtual port groups that are associated with any of the specified tags.



Note: This parameter is compatible only with standard virtual port groups. For distributed port groups, you

should use the Get-VDPortgroup cmdlet.



Required? false

Position? named

Default value None

Accept pipeline input? False

Accept wildcard characters? true



-VirtualSwitch <VirtualSwitchBase[]>

Specifies the virtual switches for which you want to retrieve their port groups.



Required? false

Position? named

Default value None

Accept pipeline input? True (ByValue)

Accept wildcard characters? true



-VM <VirtualMachine[]>

Specifies the virtual machines whose port groups you want to retrieve.



Required? false

Position? named

Default value None

Accept pipeline input? True (ByValue)

Accept wildcard characters? true



-VMHost <VMHost[]>

Specifies the hosts whose port groups you want to retrieve. The position of this parameter is deprecated and

will be changed in a future release. To avoid errors when you run existing scripts on future PowerCLI

versions, specify the parameter by name.



Required? false

Position? 1

Default value None

Accept pipeline input? True (ByValue)

Accept wildcard characters? true



<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,

ErrorAction, ErrorVariable, WarningAction, WarningVariable,

OutBuffer, PipelineVariable, and OutVariable. For more information, see

about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).



INPUTS



OUTPUTS

Zero or more VirtualPortGroup or DistributedPortGroup objects







NOTES





This cmdlet retrieves standard port groups. Retrieving distributed port groups with this cmdlet is obsolete.

Use the Get-VDPortgroup cmdlet instead.



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



Get-VirtualPortgroup -Name "VM Network"



Retrieves all port groups named "VM Network".

-------------------------- Example 2 --------------------------



$myVMHost = Get-VMHost -Name "MyVMHost"

Get-VirtualPortGroup -Name "VM Network" -VMHost $myVmHost



Retrieves the port group named "VM Network" on the specified host.

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



$myVM = Get-VM -Name "MyVM"

Get-VirtualPortGroup -VM $myVM



Retrieves all port groups to which the specified virtual machine is connected.

-------------------------- Example 4 --------------------------



$virtualSwitch = Get-VirtualSwitch -VMHost MyVMHost -Name vSwitch0

Get-VirtualPortGroup -VirtualSwitch $virtualSwitch



Retrieves all port groups which belong to the specified virtual switch.



RELATED LINKS

Online Version: https://code.vmware.com/doc/preview?id= ... Group.html

New-VirtualPortGroup

Remove-VirtualPortGroup

Set-VirtualPortGroup