PowerCLI

 View Only
Expand all | Collapse all

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

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

    Posted Apr 02, 2016 08:53 PM

    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              



  • 2.  RE: How to get List of VMs with Subnet and VLAN ID and Folder

    Posted Apr 03, 2016 01:34 PM

    Hello Again,

    Any help please?



  • 3.  RE: How to get List of VMs with Subnet and VLAN ID and Folder

    Posted Apr 04, 2016 04:19 PM

    Hi Guys

    Any help please?



  • 4.  RE: How to get List of VMs with Subnet and VLAN ID and Folder

    Posted Apr 05, 2016 05:46 AM

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

    guest os ipaddress,subnet and gateway information