Hi
I'm running this script which outputs some basic information on all the VMs in my VC, which I found somewhere on the VMware forums, however the VLan ID information is blank for all VMs.
How can I get this to work so it shows the correct Vlan ID?
Try it like this
Connect-VIServer vc
Get-VM | Select Name,Notes,
@{N="IP addr";E={[string]::Join(',',$_.Guest.IPAddress)}},
@{N="Portgroup";E={[string]::Join(',',($_.Guest.Nics | %{$_.NetworkName}))}},
@{N="VLANid";E={[string]::Join(',',(Get-VirtualPortGroup -VM $_ | %{$_.VLanId}))}} | Export-Csv "C:\Temp\ServerInfo.csv" -NoTypeInformation
In this case there is no need to pass the NetworkName since you use the VM parameter.
For each returned Portgroup, the script extracts the VLanId.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Try it like this
Connect-VIServer vc
Get-VM | Select Name,Notes,
@{N="IP addr";E={[string]::Join(',',$_.Guest.IPAddress)}},
@{N="Portgroup";E={[string]::Join(',',($_.Guest.Nics | %{$_.NetworkName}))}},
@{N="VLANid";E={[string]::Join(',',(Get-VirtualPortGroup -VM $_ | %{$_.VLanId}))}} | Export-Csv "C:\Temp\ServerInfo.csv" -NoTypeInformation
In this case there is no need to pass the NetworkName since you use the VM parameter.
For each returned Portgroup, the script extracts the VLanId.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Genius!!
Thank you so much
I'm a PowerCLI novice
Thanks, we all started there :smileygrin:
Keep playing and experimenting!
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference