5 Replies Latest reply on Dec 8, 2011 10:07 PM by vmhyperv

    I need to get all the VLAN data from entire Vcenters worth of clusters

    StuartB201110141 Novice

      Hiya,

       

      I know my good will is probabily getting a bit short here but hey I shall ask!

       

      I have several vcenters, with hundreds of vlans (literally)

       

      What I need to do is to extract, per cluster:

       

      Cluster name

      Network ranges available within the cluster

      VLAN ID

       

      As I say, if anyone can provide a script to do that, it would be much appreciated.

       

      Regards

       

      Stu

        • 1. Re: I need to get all the VLAN data from entire Vcenters worth of clusters
          Virtualinfra Master

          Use RVTOOL if you have not used before.. its a freeware.. which will fetch you the required information..under vNetwork and vSwitch column..

          link to download rvtool

           

          http://www.robware.net/

           

          Award points by clicking the below tab if the answer is helpful and correct

          • 2. Re: I need to get all the VLAN data from entire Vcenters worth of clusters
            LucD Guru
            vExpertCommunity WarriorsUser Moderators

            You could try something like this

             

            foreach($cluster in Get-Cluster){
                foreach($esx in (Get-VMHost -Location $cluster)){
                    foreach($pg in (Get-VirtualPortgroup -VMHost $esx)){
                        Select -InputObject $pg @{N="Cluster";E={$cluster.Name}},
                        @{N="VMHost";E={$esx.Name}},
                        @{N="Portgroup";E={$pg.Name}},
                        @{N="VLAN";E={$pg.VlanId}},
                        @{N="IP";E={
                                $adapter = Get-VMHostNetworkAdapter -VMHost $esx | where {$_.PortgroupName -eq $pg.Name} 
                                if($adapter){
                                    [string]::Join(',',($adapter.IP | %{$_}))
                                }
                            }}
                    }
                }
            }
            Blog: http://lucd.info | Twitter: @LucD22 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz
            • 3. Re: I need to get all the VLAN data from entire Vcenters worth of clusters
              vmhyperv Hot Shot

              LucD,

                 Can it be exported in csv format all vlan info.

               

              thanks

              vmguy

              • 4. Re: I need to get all the VLAN data from entire Vcenters worth of clusters
                LucD Guru
                vExpertCommunity WarriorsUser Moderators

                Sure, capture the output in a variable and pipe that variable to the Export-Csv cmdlet.

                 

                $report = foreach($cluster in Get-Cluster){
                    foreach($esx in (Get-VMHost -Location $cluster)){
                        foreach($pg in (Get-VirtualPortgroup -VMHost $esx)){
                            Select -InputObject $pg @{N="Cluster";E={$cluster.Name}},
                            @{N="VMHost";E={$esx.Name}},
                            @{N="Portgroup";E={$pg.Name}},
                            @{N="VLAN";E={$pg.VlanId}},
                            @{N="IP";E={
                                    $adapter = Get-VMHostNetworkAdapter -VMHost $esx | where {$_.PortgroupName -eq $pg.Name} 
                                    if($adapter){
                                        [string]::Join(',',($adapter.IP | %{$_}))
                                    }
                                }}
                        }
                    }
                }
                
                $report | Export-Csv "C:\Temp\report.csv" -NoTypeInformation -UseCulture
                Blog: http://lucd.info | Twitter: @LucD22 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz