Quantcast
Channel: VMware Communities: Message List
Viewing all articles
Browse latest Browse all 168190

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 168190

Latest Images

Trending Articles



Latest Images