Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 22 additions & 10 deletions src/modules/SdnDiag.Health.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -293,15 +293,21 @@ function Write-HealthValidationInfo {
[String[]]$Remediation,

[Parameter(Mandatory = $false)]
[ValidateSet('WARNING', 'FAIL')]
[ValidateSet('WARNING', 'FAIL', 'FAILURE', IgnoreCase = $true)]
[string]$Severity
)

switch ($Severity) {
'WARNING' {
$Severity = 'Warning'
$foregroundColor = 'Yellow'
}
'FAIL' {
$Severity = 'Failure'
$foregroundColor = 'Red'
}
'FAILURE' {
Copy link

@andrwli andrwli Jan 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider leaving a comment somewhere about the distinction between FAIL and FAILURE

$Severity = 'Failure'
$foregroundColor = 'Red'
}
}
Expand Down Expand Up @@ -352,6 +358,8 @@ function Debug-SdnFabricInfrastructure {
Enter a variable that contains a certificate or a command or expression that gets the certificate.
.PARAMETER NcRestCredential
Specifies a user account that has permission to perform this action against the Network Controller REST API. The default is the current user.
.PARAMETER SkipSummaryDisplay
Switch parameter to skip displaying the summary of results to the console.
.EXAMPLE
PS> Debug-SdnFabricInfrastructure
.EXAMPLE
Expand Down Expand Up @@ -385,7 +393,11 @@ function Debug-SdnFabricInfrastructure {

[Parameter(Mandatory = $false, ParameterSetName = 'Role')]
[Parameter(Mandatory = $false, ParameterSetName = 'ComputerName')]
[X509Certificate]$NcRestCertificate
[X509Certificate]$NcRestCertificate,

[Parameter(Mandatory = $false, ParameterSetName = 'Role')]
[Parameter(Mandatory = $false, ParameterSetName = 'ComputerName')]
[switch]$SkipSummaryDisplay
)

$script:SdnDiagnostics_Health.Cache = $null
Expand All @@ -395,7 +407,7 @@ function Debug-SdnFabricInfrastructure {

$transcriptDirectory = Get-WorkingDirectory
$transcriptPath = "{0}\SdnFabricHealthReport_{1}.txt" -f $transcriptDirectory, $dateTimeNow
Start-Transcript -Path $transcriptPath -Force
$null = Start-Transcript -Path $transcriptPath -Force
"Starting SDN Fabric Infrastructure health validation at {0}" -f $dateTimeNowFormatted | Trace-Output -Level:Information

if (Test-ComputerNameIsLocal -ComputerName $NetworkController) {
Expand Down Expand Up @@ -557,10 +569,7 @@ function Debug-SdnFabricInfrastructure {
$_ | Write-Error
}
finally {
Stop-Transcript
"Transcript saved to {0}" -f $transcriptPath | Trace-Output -Level:Information

if ($aggregateHealthReport) {
if ($aggregateHealthReport -and (-not $SkipSummaryDisplay)) {

# Display SDN Health Validation Report Header
$reportHeader = @"
Expand All @@ -580,10 +589,10 @@ function Debug-SdnFabricInfrastructure {
$overallState = 'PASS'
foreach ($report in $aggregateHealthReport) {
if ($report.Result -ieq 'FAIL') {
$overallState = 'FAIL'
$overallState = 'FAILURE'
break
}
elseif ($report.Result -ieq 'WARNING' -and $overallState -ne 'FAIL') {
elseif ($report.Result -ieq 'WARNING' -and $overallState -ne 'FAILURE') {
$overallState = 'WARNING'
}
}
Expand All @@ -592,7 +601,7 @@ function Debug-SdnFabricInfrastructure {
$stateColor = switch ($overallState) {
'PASS' { 'Green' }
'WARNING' { 'Yellow' }
'FAIL' { 'Red' }
'FAILURE' { 'Red' }
}

# Display summary
Expand Down Expand Up @@ -643,6 +652,9 @@ function Debug-SdnFabricInfrastructure {
}
}

$null = Stop-Transcript
"Transcript saved to {0}" -f $transcriptPath | Trace-Output -Level:Information

if ($script:SdnDiagnostics_Health.Cache) {
"Results for fabric health have been saved to cache for further analysis. Use 'Get-SdnFabricInfrastructureResult' to examine the results." | Trace-Output
return $script:SdnDiagnostics_Health.Cache
Expand Down