VMware Cloud Community
ganapa2000
Hot Shot
Hot Shot

VLAN Details for VM

Hi All,

Below query is showing the VLAN ID of VM, how can i merge this my script

get-vm -Name SRMTEST | Get-VirtualPortGroup | sort Name | Select Name, @{N="VLANId";E={$_.Extensiondata.Config.DefaultPortCOnfig.Vlan.VlanId}}

How can I add the above line to below script....please help..

Get-VM TESTVM | Get-HardDisk |

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

@{N="IP Address";E={[string]::Join(',',$_.Parent.guest.IPAddress)}},  #All IPs of VMs

@{N='HD Name';E={$_.Name}},

@{N='HD Capacity';E={$_.CapacityGB}}

0 Kudos
4 Replies
LucD
Leadership
Leadership

This looks like a duplicate of  2.  Re: Unable to get Port Group Name and VLAN ID for VMs

Was that answer not good ?


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

0 Kudos
ganapa2000
Hot Shot
Hot Shot

Hi,

I am not able to get the VLAN details, it is shows blank.

Please help.

0 Kudos
brunofernandez1

here the command that works for me:

get-vm -name "myvm" | Get-VirtualPortGroup | select Name, VLanId

Enviroment: vsphere 5.5 u2 and powercli 5.88 R1

------------------------------------------------------------------------------- If you found this or any other answer helpful, please consider to award points. (use Correct or Helpful buttons) Regards from Switzerland, B. Fernandez http://vpxa.info/
0 Kudos
ganapa2000
Hot Shot
Hot Shot

But mine is a Distributed Switch,

get-vm -Name SRMTEST | Get-VirtualPortGroup | sort Name | Select Name, @{N="VLANId";E={$_.Extensiondata.Config.DefaultPortCOnfig.Vlan.VlanId}}

How can I add the above line to below script....please help..

Get-VM TESTVM | Get-HardDisk |

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

@{N="IP Address";E={[string]::Join(',',$_.Parent.guest.IPAddress)}},  #All IPs of VMs

@{N='HD Name';E={$_.Name}},

@{N='HD Capacity';E={$_.CapacityGB}}

0 Kudos