VMware Cloud Community
antoniogemelli
Hot Shot
Hot Shot
Jump to solution

Get network adapter & port

Hello,

Not sure if possible,

I need something similar to Get all Vlan for the host and network info

I need to get port and network adapter info from list of VM (txt file).

Almost same info from previous script but with VM and from list.

Thanks

1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Start with the following, and let me know what is eventually missing?

Get-VM -PipelineVariable vm  | Get-NetworkAdapter -PipelineVariable vnic |

Select @{N='VM';E={$vm.Name}},

    @{N='vNIC';E={$vnic.Name}},

    ConnectionState,MacAddress,

    @{N='SwitchName';E={(Get-VirtualPortgroup -Name $_.NetworkName).VirtualSwitch.Name}},

    @{N='PGName';E={$_.NetworkName}},

    @{N='PGPort';E={$_.ExtensionData.Backing.Port.PortKey}}


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

5 Replies
LucD
Leadership
Leadership
Jump to solution

Can you indicate exactly which properties you want to see?

The port number, for example, will only work if the VM is connected to a VDS, not with a VSS.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
antoniogemelli
Hot Shot
Hot Shot
Jump to solution

Hi LucD,

I would like to see in Hardware-Network Adapters, Network label (in Network Connection) with port.

Basically I can see those fields when I click Edit Setting for VM in Vcenter.

Thanks

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

The settings on the Network Adapter you mean?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Start with the following, and let me know what is eventually missing?

Get-VM -PipelineVariable vm  | Get-NetworkAdapter -PipelineVariable vnic |

Select @{N='VM';E={$vm.Name}},

    @{N='vNIC';E={$vnic.Name}},

    ConnectionState,MacAddress,

    @{N='SwitchName';E={(Get-VirtualPortgroup -Name $_.NetworkName).VirtualSwitch.Name}},

    @{N='PGName';E={$_.NetworkName}},

    @{N='PGPort';E={$_.ExtensionData.Backing.Port.PortKey}}


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

antoniogemelli
Hot Shot
Hot Shot
Jump to solution

Thanks a lot LucD, this is exactly what I need.

Reply
0 Kudos