Get-VMNetworkAdapter

Get-VMNetworkAdapter

Gets the virtual network adapters of a virtual machine, snapshot, management OS, or of a virtual machine and management OS.

Syntax

Parameter Set: VMName
Get-VMNetworkAdapter [-VMName] <String[]> [[-Name] <String> ] [-ComputerName <String[]> ] [-IsLegacy <Boolean> ] [ <CommonParameters>]

Parameter Set: All
Get-VMNetworkAdapter [-All] [[-Name] <String> ] [-ComputerName <String[]> ] [ <CommonParameters>]

Parameter Set: ManagementOS
Get-VMNetworkAdapter [[-Name] <String> ] -ManagementOS [-ComputerName <String[]> ] [-SwitchName <String> ] [ <CommonParameters>]

Parameter Set: VMObject
Get-VMNetworkAdapter [-VM] <VirtualMachine[]> [[-Name] <String> ] [-IsLegacy <Boolean> ] [ <CommonParameters>]

Parameter Set: VMSnapshot
Get-VMNetworkAdapter [-VMSnapshot] <VMSnapshot> [[-Name] <String> ] [ <CommonParameters>]

Detailed Description

The Get-VMNetworkAdapter cmdlet gets the virtual network adapters of the specified virtual machine, snapshot, or management OS.

Parameters

-ComputerName<String[]>

Specifies one or more Hyper-V hosts on the virtual network adapters are to be retrieved. NetBIOS names, IP addresses, and fully-qualified domain names are allowable. The default is the local computer — use “localhost” or a dot (“.”) to specify the local computer explicitly.

Aliases

none

Required?

false

Position?

named

Default Value

.

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-IsLegacy<Boolean>

Specify as $TRUE to retrieve only legacy network adapters, or as $FALSE to retrieve only synthetic network adapters. If not specified, virtual network adapters of both types are retrieved.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-ManagementOS

Specifies the management OS, i.e. the virtual machine host OS.

Aliases

none

Required?

true

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Name<String>

Specifies the name of the network adapter to be retrieved.

Aliases

none

Required?

false

Position?

2

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-VM<VirtualMachine[]>

Specifies the virtual machine whose virtual network adapters are to be retrieved. . The asterisk, “*”, is the wildcard. If it is specified the cmdlet returns virtual network adapters from every virtual machine in the system.

Aliases

none

Required?

true

Position?

1

Default Value

none

Accept Pipeline Input?

true (ByValue)

Accept Wildcard Characters?

false

-VMName<String[]>

Specifies the name of the virtual machine whose network adapters are to be retrieved.

Aliases

none

Required?

true

Position?

1

Default Value

none

Accept Pipeline Input?

true (ByValue)

Accept Wildcard Characters?

true

-VMSnapshot<VMSnapshot>

Specifies the snapshot whose network adapters are to be retrieved.

Aliases

none

Required?

true

Position?

1

Default Value

none

Accept Pipeline Input?

true (ByValue)

Accept Wildcard Characters?

false

-SwitchName<String>

Specifies the name of the virtual switch whose network adapters are to be retrieved. (This parameter is available only for virtual network adapters in the management OS.)

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-All

Specifies all virtual network adapters in the system, regardless of whether the virtual network adapter is in the management OS or in a virtual machine.

Aliases

none

Required?

true

Position?

2

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

<CommonParameters>

This cmdlet supports the common parameters: -Verbose, -Debug, -ErrorAction, -ErrorVariable, -OutBuffer, and -OutVariable. For more information, see    about_CommonParameters (https://go.microsoft.com/fwlink/p/?LinkID=113216).

Inputs

The input type is the type of the objects that you can pipe to the cmdlet.

Outputs

The output type is the type of the objects that the cmdlet emits.

  • Microsoft.Virtualization.Powershell.VMInternalNetworkAdapter if ManagementOS is specified; Microsoft.Virtualization.Powershell.VMInternalNetworkAdapter and Microsoft.Virtualization.Powershell.VMNetworkAdapter if All is specified;Microsoft.Virtualization.Powershell.VMNetworkAdapter in all other cases.

Examples

Example 1

Gets virtual network adapters from all virtual machines on the local Hyper-V host.

PS C:\> Get-VMNetworkAdapter –VMName *

Example 2

Gets the virtual network adapters in the ManagementOS (i.e. the local Hyper-V host).

PS C:\> Get-VMNetworkAdapter -ManagementOS

Example 3

Gets virtual network adapters from all virtual machines as well as the management OS.

PS C:\> Get-VMNetworkAdapter -All