Edit

Share via


Get-VMNetworkAdapterPortId

Gets the VFP/VSwitch port ID.

Syntax

Default (Default)

Get-VMNetworkAdapterPortId
    [[-VMName] <String>]
    [[-VMNetworkAdapterName] <String>]
    [<CommonParameters>]

Description

The Get-VMNetworkAdapterPortId cmdlet gets the VFP/VSwitch port ID for a virtual machine or infrastructure port. This cmdlet also returns the friendly name of the virtual switch to which the port is attached and the port name.

Examples

Example 1: Get the port ID for a virtual machine network adapter

PS C:\> ($switchName, $portId, $portName) = Get-VMNetworkAdapterPortId -VMName "vm1" -VMNetworkAdapterName "VMAdapter"

Example 2: Get the port ID for an infrastructure port

PS C:\> ($switchName, $portId, $portName) = Get-VMNetworkAdapterPortId -VMNetworkAdapterName "HostAdapter"

This command gets the port ID for an infrastructure port, and then saves it to the specified variables.

Parameters

-VMName

Specifies the name of the virtual machine for which to retrieve the port ID.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:0
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-VMNetworkAdapterName

Specifies the name of the virtual machine network adapter for which to retrieve the port ID.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:1
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

Inputs

None

Outputs

Object