I'm trying to build a script that extracts all PortGroups with a certain VLAN ID. The only thing that's missing is the output :smileywink: Obviously I'm doing something completely wrong, but I don't know what. Somebody can help me out?
Get-VIServer xxx +-User +xxx +-Password +xxx
$MyHost = Get-VMHost xxx
$HostView = Get-View $MyHost.ID
$NetworkSystem = get-view $HostView.ConfigManager.NetworkSystem
$AllPortGroups = get-view $NetworkSystem.NetworkInfo.Portgroup | where {$_.HostPortGroupSpec.VlanId > 0 }
Foreach ($HostPortGroup in $AllPortGroups){
write-output $_.HostPortGroupSpec.Name
}