Hi,
Get-VM xxx| Select Name,
@{N="IP addr";E={[string]::Join(',',$_.Guest.IPAddress)}},
@{N="MAC addr";E={[string]::Join(',',($_.Guest.Nics | %{$_.MacAddress}))}},
@{N="NIC type";E={[string]::Join(',',($_.Guest.Nics | %{$_.Device.Type}))}},
@{N="VLANid";E={(Get-VM $_ |Get-NetworkAdapter |select NetworkName )}}
For Std switch this gives me no info for vlan id
Get-VM xxx| Get-NetworkAdapter gives all info well tho
------------------------ ****** ---------------------------------------- ****** -------------------------------
for VDS same code above gives info well, but the name of vlan comes as , I would need the xxx in tho..
@{NetworkName=xxx} |
Can some help ..
Try like this
Get-VM xxx | Select Name,
@{N="IP addr";E={[string]::Join(',',$_.Guest.IPAddress)}},
@{N="MAC addr";E={[string]::Join(',',($_.Guest.Nics | %{$_.MacAddress}))}},
@{N="NIC type";E={[string]::Join(',',($_.Guest.Nics | %{$_.Device.Type}))}},
@{N="VLANid";E={(Get-VM $_ |Get-NetworkAdapter |select -ExpandProperty NetworkName )}}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
well it worked ... but taking generations to pull the info
You can try modifying the last line in that script to read:
@{N="VLANid";E={($_.NetworkAdapters.NetworkName)}}
Your environment may be different but it made this faster for me.