Skip to main content

vCD + NSX | How to get complete list of NSX edges in excel sheet

In one of our project, I was asked to extract a exhaustive report of NSX edges which should contain Edge ID, Edge Name, Edge Size, Datacenter Name and all other properties of NSX edge which can be included in the report.

I did it simply using PowerNSX (PowerShell module for NSX). Below is the script. If you understand powershell even a bit, you can add many more properties in this script.

Just copy and paste in Windows Powershell ISE(it work best with ISE console)

######Start

$vCD = Read-host "Enter vCD URL starting with https  "
$NSX = Read-host "Enter NSX Manager IP address  "

Connect-CIServer $vCD  #It will connect vCD

Connect-NsxServer -NsxServer $NSX #To connect NSX
$Orgs = Get-Org
$Edges = Get-NsxEdge
$myView = @()
Foreach ($Edge in $Edges) {
    $Report = [PSCustomObject] @{
    Edge_Name = $Edge.Name
Edge_ID = $edge.id
EdgeApplianceName_Active = $edge.edgeSummary.appliancesSummary.vmNameOfActiveVse
Edge_Size = $edge.edgeSummary.appliancesSummary.applianceSize
HA_Status = $edge.features.highAvailability.enabled
VcdOrg = ($orgs | where {$_.Id -match $edge.Tenant})
       }
    $MyView += $Report
}
$MyView | out-gridview
######End

# I personally prefer to take output as in "out-gridview" you can extract the report in .xlsx file as well.

Comments

  1. People who knows me, prefer to call me rather than putting comments here ;)
    I got to know that above script didn't work and ended up with error. When I checked I found that people were modifying the script content. For example, in first line $vCD = Read-host "Enter vCD URL starting with https ", you need not to mention vCD URL in quote. Just leave it as it is and run the scirpt. It will automatically ask fro vCD URL and then you need to mention.

    Please don't shy to ask anything here. Keep asking, keep growing!

    ReplyDelete
  2. This is a very useful script to collect edge details. It helped me a lot to extract edge details before performing any activity and saves lots of efforts and time.

    Thanks Gautam, I know you have very good scripting knowledge. Keep it up...

    ReplyDelete

Post a comment

Popular posts from this blog

Network Migration | VLAN to VXLAN

NSX-T | Getting Started with PowerCLI

Automate Power on Operations using PS

NSX-T | Security