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.fqdn
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.
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.fqdn
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.
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.
ReplyDeleteThanks Gautam, I know you have very good scripting knowledge. Keep it up...