A small segment of PowerCLI that helps you to retrieve distributed virtual portgroups from an ESXi hostname.

get-vmhost -Name <hostname> | Get-VirtualPortGroup | sort Name | Select Name, @{N="VLANId";E={$_.Extensiondata.Config.DefaultPortCOnfig.Vlan.VlanId}}

Note: You’ll need to be authenticated to a given vCenter prior to running this command.