VMware Cloud Community
fborges555
Enthusiast
Enthusiast
Jump to solution

Network Name

Hi

I am trying to get the Network Name and VlanID but this statement is only showing me the VLANid

@{N='VLANINFO';E={(Get-VirtualPortgroup -Name (Get-NetWorkAdapter -VM $_).NetworkName).VlanId -join '|'}}

Where did I go worng?

Thanks a bunch everyone

Reply
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

You could do the following.

But be aware that this will not work correctly for VMs that have more than 1 vNIC, since the result will be an array.

Get-VM | Select Name,

@{N='VLANINFO';E={Get-Virtualportgroup -Name (Get-NetworkAdapter -VM $_).NetworkName | %{$_.Name,$_.VlanId -join '|'}}}


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

View solution in original post

Reply
0 Kudos
1 Reply
LucD
Leadership
Leadership
Jump to solution

You could do the following.

But be aware that this will not work correctly for VMs that have more than 1 vNIC, since the result will be an array.

Get-VM | Select Name,

@{N='VLANINFO';E={Get-Virtualportgroup -Name (Get-NetworkAdapter -VM $_).NetworkName | %{$_.Name,$_.VlanId -join '|'}}}


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

Reply
0 Kudos