WilliamLam.com

  • About
    • About
    • Privacy
  • VMware Cloud Foundation
  • VKS
  • Homelab
    • Resources
    • Nested Virtualization
  • VMware Nostalgia
  • Apple
You are here: Home / Automation / Quick Tip - Retrieving NSX segment information from vCenter Server

Quick Tip - Retrieving NSX segment information from vCenter Server

06.07.2024 by William Lam // Leave a Comment

Since vSphere 7.0, it has been much simpler to correlate between an NSX network segment defined in NSX Manager and its representation as a vSphere Distributed Virtual Portgroup (DVG) in vCenter Server as demonstrated in screenshot below using the vSphere UI.


With the additional NSX information such as NSX Transport Zone ID, Transport Zone ID Name, Logical Switch ID, Segment Name and VNI (Virtual Network Identifier), users can streamline debugging and troubleshooting issues with their network team by quickly providing this relevant information.

I recently had a user ask about retrieving the VNI information for a given NSX segment in vCenter Server using PowerCLI, so here is a quick snippet including other NSX information for those interested.

The NSX Transport Zone Name, ID and Logical Switch ID and Segment ID is part of the config property of a DVPG. Unlike the other NSX properties which are found on the main DVPG resource, the VNI property is under the defaultPortConfig property.

If we put all of this together, here is an example PowerCLI snippet that will return all DVPGs that are NSX backed and output the respective NSX properties as mentioned above:

$dvpgs = Get-VDPortgroup

$results = @()
foreach ($dvpg in $dvpgs) {
    if($dvpg.ExtensionData.Config.BackingType -eq "nsx") {
        $tmp = [pscustomobject]@{
            Name = $dvpg.Name
            TransportZoneUuid = $dvpg.ExtensionData.Config.TransportZoneUuid
            TransportZoneName = $dvpg.ExtensionData.Config.TransportZoneName
            LogicalSwitchUuid = $dvpg.ExtensionData.Config.LogicalSwitchUuid
            SegmentId = $dvpg.ExtensionData.Config.SegmentId
            VNI = $dvpg.ExtensionData.Config.DefaultPortConfig.VNI.Value
        }
        $results+=$tmp
    }
}
$results

Here is an example output from the script:

More from my site

  • PowerCLI automation for VMware Private AI Foundation with NVIDIA (PAIF-N)
  • Automated VMware Cloud Foundation (VCF) Workload Domain deployment using PowerVCF
  • Quick Tip - How do I tell if NSX-V or NSX-T is installed?
  • ESXi on GMKtec NucBox K11
  • Quick Tip - VMware Cloud Foundation (VCF) Bringup fails without persistent ESX-OSData

Categories // Automation, NSX, PowerCLI, VMware Cloud Foundation, vSphere 8.0 Tags // NSX, PowerCLI, VMware Cloud Foundation

Thanks for the comment!Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Search

Thank Author

Author

William is Distinguished Platform Engineering Architect in the VMware Cloud Foundation (VCF) Division at Broadcom. His primary focus is helping customers and partners build, run and operate a modern Private Cloud using the VMware Cloud Foundation (VCF) platform.

Connect

  • Bluesky
  • Email
  • GitHub
  • LinkedIn
  • Mastodon
  • Reddit
  • RSS
  • Twitter
  • Vimeo

Recent

  • Programmatically accessing the Broadcom Compatibility Guide (BCG) 05/06/2025
  • Quick Tip - Validating Broadcom Download Token  05/01/2025
  • Supported chipsets for the USB Network Native Driver for ESXi Fling 04/23/2025
  • vCenter Identity Federation with Authelia 04/16/2025
  • vCenter Server Identity Federation with Kanidm 04/10/2025

Advertisment

Privacy & Cookies: This site uses cookies. By continuing to use this website, you agree to their use.
To find out more, including how to control cookies, see here: Cookie Policy

Copyright WilliamLam.com © 2025

 

Loading Comments...