You can use PowerCLI and the NSX-T REST API to pull the required information. Here's an example of how to connect to NSX-T, gather the segments, and extract the desired information:
# Connect to NSX-T Manager
$nsxtManager = "https://your-nsxt-manager-ip"
$nsxtUsername = "your-username"
$nsxtPassword = "your-password"
# Define the API endpoint for segments
$segmentsEndpoint = "/api/v1/logical-switches"
# Create the session headers
$headers = @{
"Authorization" = "Basic " + [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes("$nsxtUsername:$nsxtPassword"))
}
# Fetch the segment data
$response = Invoke-RestMethod -Uri "$nsxtManager$segmentsEndpoint" -Method Get -Headers $headers -SkipCertificateCheck
# Initialize an array to store the segment information
$segmentInfo = @()
# Loop through each segment and extract the desired fields
foreach ($segment in $response.results) {
$segmentDetails = New-Object PSObject -property @{
"display_name" = $segment.display_name
"uplink_teaming_policy_name" = $segment.uplink_teaming_policy_name
}
$segmentInfo += $segmentDetails
}
# Export the data to a CSV file
$segmentInfo | Export-Csv -Path "C:\path\to\output\segments_info.csv" -NoTypeInformation
Original Message:
Sent: Oct 17, 2024 11:54 AM
From: AughBT
Subject: Script to display NSXT segment information
HI There
I need a powercli script that does the following.
I need a script to connect to NSXT
I then need to script to pull the following information about every segment
1. display_name
2. uplink_teaming_policy_name
I want the output in .csv format
e.g.
display_name,uplink_teaming_policy_name
segment-vlan1308,Uplink_1.Uplink_2-
Any ideas?
thanks
------------------------------
NetworkAdmin9845
------------------------------