Quantcast
Channel: VMware Communities : Discussion List - All Communities
Viewing all articles
Browse latest Browse all 176483

why is this script not getting the VLAN ID?

$
0
0

Hi I need to gather the VLAN information against my environment to check to see if VLAN's have been configured

 

$report = @()

foreach($esx in Get-VMHost){

    $vms = Get-VM -Location $esx

    foreach($pg in (Get-VirtualPortGroup -VMHost $esx)){

        $vms | where {$_.Guest.Nics | where {$_.NetworkName -eq $pg.Name}} | foreach {

            $Report += New-Object PSObject -Property @{

                "Host"=$esx.Name

                "VM"=$_.Name

                "VLAN ID"=$pg.VlanId

                "Port Group"=$pg.Name

                "IP"=[string]::Join(',',($_.Guest.Nics | where {$_.NetworkName -eq $pg.Name} | %{$_.IPAddress | %{$_}}))

            }

        }

    }

}

$report | Export-Csv "C:\testVLAN-report.csv" -NoTypeInformation -UseCulture

 

 

this gathers most of the information but isn't pull back the VLAN ID?  anybody know why?


Viewing all articles
Browse latest Browse all 176483

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>