VMware Cloud Community
KinnowGrower
Contributor
Contributor

How to get List of VMs with Subnet and VLAN ID and Folder

Hello everyone,

I am very very new to Vsphere CLI and new here as well. Found some very  useful script here to get list of VMs with IP address and VLAN ID. My requirement is little different. How can i get list of VMs in a data center with VM name, Portgroup, VLAN ID and ALSO network subnet (e.g. the VM is in 192.168.3.1/29 Subnet). Is it even possible? and also folder name > Here is how the folder hierarchy is


Virtualcenter-->

Folder--->

Datacenter->

             ---->Customer

                       ->Customer1

                                   --->Folder64

                                                ---VM1

                                                ---VM2

                                                ---VM3

                       ->Customer2

                                    --->Folder786

                                                ---VM1

                                                ---VM2

                                                ---VM3

 

So, is it possible to get list of  VMs for each customer separately with folder name like listed below


VMname, Customer1, folder64, subnet/29, IP address, portgroup, VLAN ID


However i am getting the list as listed below (Missing folder name Customer1) the folder one level above Folder64 and Subnet number with/28 or /29 etc)


VMname, Folder64, IP address, portgroup and VLAN ID using this


Get-DataCenter Datcenter-Name |

    Get-VM | Select Name,

    @{N="Folder";E={$_.Folder.Name}},

    @{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}))}}


It is Vcenter 4.0 esxi

Please help


Thanks              

Tags (1)
Reply
0 Kudos
3 Replies
KinnowGrower
Contributor
Contributor

Hello Again,

Any help please?

Reply
0 Kudos
KinnowGrower
Contributor
Contributor

Hi Guys

Any help please?

Reply
0 Kudos
vin01
Expert
Expert

Can you go through this thread..it might be helpful

guest os ipaddress,subnet and gateway information

Regards Vineeth.K
Reply
0 Kudos