From a39112b8a72ac467a685171250ec2cec645fd977 Mon Sep 17 00:00:00 2001 From: bhumitra nagar Date: Fri, 3 Feb 2023 13:26:35 -0800 Subject: [PATCH] feat: update `Publish-*` methods for JSON generation (#79) Updated `Publish-*` cmdlets to support JSON generation for: - `Publish-BackupStatus` - `Publish-NsxtTransportNodeStatus` - `Publish-NsxtTier0BgpStatus` - `Publish-SnapshotStatus` - `Publish-LocalUserExpiry` - `Publish-StorageCapacityHealth` Added 2 additional functions: - `Publish-NsxtHealthNonSOS` - `Publish-ComponentConnectivityHealthNonSOS` Signed-off-by: bhumitra nagar --- VMware.CloudFoundation.Reporting.psm1 | 560 +++++++++++++++++++++----- 1 file changed, 449 insertions(+), 111 deletions(-) diff --git a/VMware.CloudFoundation.Reporting.psm1 b/VMware.CloudFoundation.Reporting.psm1 index addbcef0..220cbc0a 100644 --- a/VMware.CloudFoundation.Reporting.psm1 +++ b/VMware.CloudFoundation.Reporting.psm1 @@ -40,6 +40,21 @@ if ($PSEdition -eq 'Desktop') { } } +####################################################################################################################### +############################# J S O N O U T P U T F I L E N A M E S ############################################ + + +Set-Variable -Name "backupJsonSuffix" -value "backup-status.json" -scope global +Set-Variable -Name "nsxtTransportJsonSuffix" -value "nsxttransportnode-status.json" -scope global +Set-Variable -Name "nsxttntunnelJsonSuffix" -value "nsxttntunnel-status.json" -scope global +Set-Variable -Name "nsxttier0bgpJsonSuffix" -value "nsxttier0bgp-status.json" -scope global +Set-Variable -Name "snapshotJsonSuffix" -value "snapshot-status.json" -scope global +Set-Variable -Name "localuserexpiryJsonSuffix" -value "localuserexpiry-status.json" -scope global +Set-Variable -Name "storageCapacityHealthJsonSuffix" -value "storagecapacityhealth-status.json" -scope global +Set-Variable -Name "componentConnectivityHealthNonSOSJsonSuffix" -value "componentconnectivityhealthnonsos-status.json" -scope global +Set-Variable -Name "nsxtCombinedHealthNonSOSJsonSuffix" -value "nsxtcombinedhealthnonsos-status.json" -scope global + + ####################################################################################################################### ############################# C O M B I N E D O P E R A T I O N S F U N C T I O N S ############################ @@ -94,7 +109,7 @@ Function Invoke-VcfHealthReport { $workflowMessage = "Workload Domain ($workloadDomain)" $commandSwitch = "-workloadDomain $workloadDomain" } - if ($PsBoundParameters.ContainsKey('failureOnly')) { + if ($PsBoundParameters.ContainsKey('failureOnly')) { $failureOnlySwitch = " -failureOnly" } @@ -136,7 +151,7 @@ Function Invoke-VcfHealthReport { # Generating the NTP Health Data Using the SoS Data Write-LogMessage -Type INFO -Message "Generating the NTP Health Report using the SoS output for $workflowMessage." $ntpHtml = Invoke-Expression "Publish-NtpHealth -json $jsonFilePath -html $($failureOnlySwitch)"; $reportData += $ntpHtml - + # Generating the vCenter Server Health Data Using the SoS Data Write-LogMessage -Type INFO -Message "Generating the vCenter Server Health Report using the SoS output for $workflowMessage." $vcenterHtml = Invoke-Expression "Publish-VcenterHealth -json $jsonFilePath -html $($failureOnlySwitch)"; $reportData += $vcenterHtml @@ -160,7 +175,7 @@ Function Invoke-VcfHealthReport { # Generating the vSAN Storage Policy Health Data Using the SoS Data Write-LogMessage -Type INFO -Message "Generating the vSAN Storage Policy Health Report using the SoS output for $workflowMessage." $vsanPolicyHtml = Invoke-Expression "Publish-VsanStoragePolicy -json $jsonFilePath -html $($failureOnlySwitch)"; $reportData += $vsanPolicyHtml - + # Generating the NSX Manager Health Data Using SoS output and Supplimental PowerShell Request Functions Write-LogMessage -Type INFO -Message "Generating the NSX-T Data Center Health Report using the SoS output for $workflowMessage." $nsxtHtml = Invoke-Expression "Publish-NsxtCombinedHealth -server $sddcManagerFqdn -user $sddcManagerUser -pass $sddcManagerPass -json $jsonFilePath $($commandSwitch) $($failureOnlySwitch)"; $reportData += $nsxtHtml @@ -271,7 +286,7 @@ Function Invoke-VcfAlertReport { $workflowMessage = "Workload Domain ($workloadDomain)" $commandSwitch = "-workloadDomain $workloadDomain" } - if ($PsBoundParameters.ContainsKey('failureOnly')) { + if ($PsBoundParameters.ContainsKey('failureOnly')) { $commandSwitch = $commandSwitch + " -failureOnly" } @@ -610,7 +625,7 @@ Function Invoke-VcfPasswordPolicy { $sddcManagerPasswordExpirationHtml = Invoke-Expression "Publish-SddcManagerPasswordExpiration -server $sddcManagerFqdn -user $sddcManagerUser -pass $sddcManagerPass -sddcRootPass $sddcRootPass $($commandSwitch)" $sddcManagerPasswordComplexityHtml = Invoke-Expression "Publish-SddcManagerPasswordComplexity -server $sddcManagerFqdn -user $sddcManagerUser -pass $sddcManagerPass -sddcRootPass $sddcRootPass $($commandSwitch)" $sddcManagerAccountLockoutHtml = Invoke-Expression "Publish-SddcManagerAccountLockout -server $sddcManagerFqdn -user $sddcManagerUser -pass $sddcManagerPass -sddcRootPass $sddcRootPass $($commandSwitch)" - + Write-LogMessage -Type INFO -Message "Collecting vCenter Single Sign-On Password Policies for $workflowMessage." $ssoPasswordExpirationHtml = Invoke-Expression "Publish-SsoPasswordPolicy -server $sddcManagerFqdn -user $sddcManagerUser -pass $sddcManagerPass -policy PasswordExpiration $($commandSwitch)" $ssoPasswordComplexityHtml = Invoke-Expression "Publish-SsoPasswordPolicy -server $sddcManagerFqdn -user $sddcManagerUser -pass $sddcManagerPass -policy PasswordComplexity $($commandSwitch)" @@ -985,7 +1000,7 @@ Function Publish-ConnectivityHealth { $jsonInputCheck = $targetContent.Connectivity.'Connectivity Status' # Extract Data from the provided SOS JSON if (($jsonInputCheck | Measure-Object).Count -lt 1) { Write-Warning 'Connectivity Status data not found in the JSON file: SKIPPED' - } else { + } else { # ESXi SSH Status $jsonInputData = $targetContent.Connectivity.'Connectivity Status'.'ESXi SSH Status' # Extract Data from the provided SOS JSON @@ -1201,7 +1216,7 @@ Function Publish-EsxiHealth { $jsonComputeCheck = $targetContent.Compute # Extract Data from the provided SOS JSON if (($jsonComputeCheck | Measure-Object).Count -lt 1) { Write-Warning 'Compute data not found in the JSON file: SKIPPED' - } else { + } else { # ESXi Overall Health Status $jsonInputData = $targetContent.Compute.'ESXi Overall Health' # Extract Data from the provided SOS JSON if ($PsBoundParameters.ContainsKey('failureOnly')) { @@ -1273,7 +1288,7 @@ Function Publish-EsxiHealth { } $allLicenseObject - if (($jsonComputeCheck | Measure-Object).Count -gt 0) { + if (($jsonComputeCheck | Measure-Object).Count -gt 0) { if ($allDiskObject.Count -eq 0) { $addNoIssues = $true } if ($addNoIssues) { $allDiskObject = $allDiskObject | Sort-Object Component, Resource | ConvertTo-Html -Fragment -PreContent '

ESXi Disk Health Status

' -PostContent '

No issues found.

' @@ -1339,7 +1354,7 @@ Function Publish-NsxtHealth { $jsonInputCheck = $targetContent.General.'NSX Health' # Extract Data from the provided SOS JSON if (($jsonInputCheck | Measure-Object).Count -lt 1) { Write-Warning 'NSX Health data not found in the JSON file: SKIPPED' - } else { + } else { # NSX Manager Health $component = 'NSX Manager' @@ -2006,7 +2021,7 @@ Function Publish-VsanHealth { $jsonInputCheck = $targetContent.vSAN # Extract Data from the provided SOS JSON if (($jsonInputCheck | Measure-Object).Count -lt 1) { Write-Warning 'vSAN data not found in the JSON file: SKIPPED' - } else { + } else { # vSAN Cluster Health Status $jsonInputData = $targetContent.vSAN.'Cluster vSAN Status' # Extract Data from the provided SOS JSON @@ -2201,6 +2216,7 @@ Function Publish-BackupStatus { report. The cmdlet connects to SDDC Manager using the -server, -user, and password values: - Validates that network connectivity is available to the SDDC Manager instance - Performs checks on the backup status and outputs the results + - outputJson parameter takes in name of the folder to save the json. Filename is autogenerated. .EXAMPLE Publish-BackupStatus -server sfo-vcf01.sfo.rainpole.io -user admin@local -pass VMw@re1!VMw@re1! -allDomains @@ -2213,6 +2229,11 @@ Function Publish-BackupStatus { .EXAMPLE Publish-BackupStatus -server sfo-vcf01.sfo.rainpole.io -user admin@local -pass VMw@re1!VMw@re1! -workloadDomain sfo-w01 This example will publish the backup status for the vCenter Server instances, and NSX Local Manager clusters in Workload Domain sfo-w01. + + .EXAMPLE + Publish-BackupStatus -server sfo-vcf01.sfo.rainpole.io -user admin@local -pass VMw@re1!VMw@re1! -allDomains -outputJson F:\Reporting + This example will generate a json for the backup status for the vCenter Server instances, and NSX Local Manager clusters in a VMware Cloud Foundation instance + and saves it under F:\Reporting with filename -backup-status.json #> Param ( @@ -2221,7 +2242,8 @@ Function Publish-BackupStatus { [Parameter (Mandatory = $true)] [ValidateNotNullOrEmpty()] [String]$pass, [Parameter (ParameterSetName = 'All-WorkloadDomains', Mandatory = $true)] [ValidateNotNullOrEmpty()] [Switch]$allDomains, [Parameter (ParameterSetName = 'Specific-WorkloadDomain', Mandatory = $true)] [ValidateNotNullOrEmpty()] [String]$workloadDomain, - [Parameter (Mandatory = $false)] [ValidateNotNullOrEmpty()] [Switch]$failureOnly + [Parameter (Mandatory = $false)] [ValidateNotNullOrEmpty()] [Switch]$failureOnly, + [Parameter (Mandatory = $false)] [ValidateNotNullOrEmpty()] $outputJson ) Try { @@ -2261,14 +2283,20 @@ Function Publish-BackupStatus { } } - if ($allBackupStatusObject.Count -eq 0) { $addNoIssues = $true } + if ($PsBoundParameters.ContainsKey('outputJson')) { + $json = Start-CreateOutputJsonDirectory -jsonFolder $outputJson -jsonFileSuffix $backupJsonSuffix + $allBackupStatusObject | ConvertTo-JSON -Depth 10 | Out-File $json + Write-Output "JSON Created at $json" + } else { + if ($allBackupStatusObject.Count -eq 0) { $addNoIssues = $true } if ($addNoIssues) { $allBackupStatusObject = $allBackupStatusObject | Sort-Object Component, Resource, Element | ConvertTo-Html -Fragment -PreContent '

Backups Status

' -PostContent "

No issues found.

Please verify that each successful file-based backup exists on the destination.

" } else { $allBackupStatusObject = $allBackupStatusObject | Sort-Object Component, Resource, Element | ConvertTo-Html -Fragment -PreContent '

Backups Status

' -PostContent "

Please verify that each successful file-based backup exists on the destination.

" -As Table } - $allBackupStatusObject = Convert-CssClass -htmldata $allBackupStatusObject - $allBackupStatusObject + $allBackupStatusObject = Convert-CssClass -htmldata $allBackupStatusObject + $allBackupStatusObject + } } } } @@ -2301,6 +2329,11 @@ Function Publish-NsxtTransportNodeStatus { .EXAMPLE Publish-NsxtTransportNodeStatus -server sfo-vcf01.sfo.rainpole.io -user admin@local -pass VMw@re1!VMw@re1! -workloadDomain sfo-w01 This example will publish the BGP status for the NSX transport nodes in a VMware Cloud Foundation instance for a workload domain named sfo-w01. + + .EXAMPLE + Publish-NsxtTransportNodeStatus -server sfo-vcf01.sfo.rainpole.io -user admin@local -pass VMw@re1!VMw@re1! -allDomains -outputJson F:\Reporting + This example will generate a json for the status of all NSX transport nodes in a VMware Cloud Foundation instance. + and saves it under F:\Reporting with filename -nsxttransportnode-status.json #> Param ( [Parameter (Mandatory = $true)] [ValidateNotNullOrEmpty()] [String]$server, @@ -2308,7 +2341,9 @@ Function Publish-NsxtTransportNodeStatus { [Parameter (Mandatory = $true)] [ValidateNotNullOrEmpty()] [String]$pass, [Parameter (ParameterSetName = 'All-WorkloadDomains', Mandatory = $true)] [ValidateNotNullOrEmpty()] [Switch]$allDomains, [Parameter (ParameterSetName = 'Specific-WorkloadDomain', Mandatory = $true)] [ValidateNotNullOrEmpty()] [String]$workloadDomain, - [Parameter (Mandatory = $false)] [ValidateNotNullOrEmpty()] [Switch]$failureOnly + [Parameter (Mandatory = $false)] [ValidateNotNullOrEmpty()] [Switch]$failureOnly, + [Parameter (Mandatory = $false)] [ValidateNotNullOrEmpty()] $outputJson + ) Try { @@ -2335,16 +2370,22 @@ Function Publish-NsxtTransportNodeStatus { } } - if ($allNsxtTransportNodeStatusObject.Count -eq 0) { - $addNoIssues = $true - } - if ($addNoIssues) { - $allNsxtTransportNodeStatusObject = $allNsxtTransportNodeStatusObject | Sort-Object Domain, Resource, Element | ConvertTo-Html -Fragment -PreContent '

NSX Transport Node Status

' -PostContent '

No issues found.

' + if ($PsBoundParameters.ContainsKey('outputJson')) { + $json = Start-CreateOutputJsonDirectory -jsonFolder $outputJson -jsonFileSuffix $nsxtTransportJsonSuffix + $allNsxtTransportNodeStatusObject | ConvertTo-JSON -Depth 10 | Out-File $json + Write-Output "JSON Created at $json" } else { - $allNsxtTransportNodeStatusObject = $allNsxtTransportNodeStatusObject | Sort-Object Domain, Resource, Element | ConvertTo-Html -Fragment -PreContent '

NSX Transport Node Status

' -As Table + if ($allNsxtTransportNodeStatusObject.Count -eq 0) { + $addNoIssues = $true + } + if ($addNoIssues) { + $allNsxtTransportNodeStatusObject = $allNsxtTransportNodeStatusObject | Sort-Object Domain, Resource, Element | ConvertTo-Html -Fragment -PreContent '

NSX Transport Node Status

' -PostContent '

No issues found.

' + } else { + $allNsxtTransportNodeStatusObject = $allNsxtTransportNodeStatusObject | Sort-Object Domain, Resource, Element | ConvertTo-Html -Fragment -PreContent '

NSX Transport Node Status

' -As Table + } + $allNsxtTransportNodeStatusObject = Convert-CssClass -htmldata $allNsxtTransportNodeStatusObject + $allNsxtTransportNodeStatusObject } - $allNsxtTransportNodeStatusObject = Convert-CssClass -htmldata $allNsxtTransportNodeStatusObject - $allNsxtTransportNodeStatusObject } } } @@ -2377,6 +2418,13 @@ Function Publish-NsxtTransportNodeTunnelStatus { .EXAMPLE Publish-NsxtTransportNodeTunnelStatus -server sfo-vcf01.sfo.rainpole.io -user admin@local -pass VMw@re1!VMw@re1! -workloadDomain sfo-w01 This example will publish the BGP status for the NSX transport node tunnels in a VMware Cloud Foundation instance for a workload domain named sfo-w01. + + .EXAMPLE + Publish-NsxtTransportNodeTunnelStatus -server sfo-vcf01.sfo.rainpole.io -user admin@local -pass VMw@re1!VMw@re1! -allDomains -outputJson F:\Reporting + This example will generate a json for the status of all NSX transport node tunnels in a VMware Cloud Foundation instance + and saves it under F:\Reporting with filename -nsxttntunnel-status.json + + #> Param ( [Parameter (Mandatory = $true)] [ValidateNotNullOrEmpty()] [String]$server, @@ -2384,7 +2432,9 @@ Function Publish-NsxtTransportNodeTunnelStatus { [Parameter (Mandatory = $true)] [ValidateNotNullOrEmpty()] [String]$pass, [Parameter (ParameterSetName = 'All-WorkloadDomains', Mandatory = $true)] [ValidateNotNullOrEmpty()] [Switch]$allDomains, [Parameter (ParameterSetName = 'Specific-WorkloadDomain', Mandatory = $true)] [ValidateNotNullOrEmpty()] [String]$workloadDomain, - [Parameter (Mandatory = $false)] [ValidateNotNullOrEmpty()] [Switch]$failureOnly + [Parameter (Mandatory = $false)] [ValidateNotNullOrEmpty()] [Switch]$failureOnly, + [Parameter (Mandatory = $false)] [ValidateNotNullOrEmpty()] $outputJson + ) Try { @@ -2409,19 +2459,24 @@ Function Publish-NsxtTransportNodeTunnelStatus { $nsxtTransportNodeTunnelStatus = Request-NsxtTransportNodeTunnelStatus -server $server -user $user -pass $pass -domain $workloadDomain; $allNsxtTransportNodeTunnelStatusObject += $nsxtTransportNodeTunnelStatus } } - - if ($allNsxtTransportNodeTunnelStatusObject.Count -eq 0) { $addNoIssues = $true } - if ($allNsxtTransportNodeTunnelStatusObject.Count -ne 0) { - if ($addNoIssues) { - $allNsxtTransportNodeTunnelStatusObject = $allNsxtTransportNodeTunnelStatusObject | Sort-Object Domain, Resource, Element | ConvertTo-Html -Fragment -PreContent '

NSX Transport Node Tunnel Status

' -PostContent '

No issues found.

' + if ($PsBoundParameters.ContainsKey('outputJson')) { + $json = Start-CreateOutputJsonDirectory -jsonFolder $outputJson -jsonFileSuffix $nsxttntunnelJsonSuffix + $allNsxtTransportNodeTunnelStatusObject | ConvertTo-JSON -Depth 10 | Out-File $json + Write-Output "JSON Created at $json" + } else { + if ($allNsxtTransportNodeTunnelStatusObject.Count -eq 0) { $addNoIssues = $true } + if ($allNsxtTransportNodeTunnelStatusObject.Count -ne 0) { + if ($addNoIssues) { + $allNsxtTransportNodeTunnelStatusObject = $allNsxtTransportNodeTunnelStatusObject | Sort-Object Domain, Resource, Element | ConvertTo-Html -Fragment -PreContent '

NSX Transport Node Tunnel Status

' -PostContent '

No issues found.

' + } else { + $allNsxtTransportNodeTunnelStatusObject = $allNsxtTransportNodeTunnelStatusObject | Sort-Object Domain, Resource, Element | ConvertTo-Html -Fragment -PreContent '

NSX Transport Node Tunnel Status

' -As Table + } + $allNsxtTransportNodeTunnelStatusObject = Convert-CssClass -htmlData $allNsxtTransportNodeTunnelStatusObject } else { - $allNsxtTransportNodeTunnelStatusObject = $allNsxtTransportNodeTunnelStatusObject | Sort-Object Domain, Resource, Element | ConvertTo-Html -Fragment -PreContent '

NSX Transport Node Tunnel Status

' -As Table + $allNsxtTransportNodeTunnelStatusObject = $allNsxtTransportNodeTunnelStatusObject | ConvertTo-Html -Fragment -PreContent '

NSX Transport Node Tunnel Status

' -PostContent '

No NSX Transport Node Tunnels found.

' } - $allNsxtTransportNodeTunnelStatusObject = Convert-CssClass -htmlData $allNsxtTransportNodeTunnelStatusObject - } else { - $allNsxtTransportNodeTunnelStatusObject = $allNsxtTransportNodeTunnelStatusObject | ConvertTo-Html -Fragment -PreContent '

NSX Transport Node Tunnel Status

' -PostContent '

No NSX Transport Node Tunnels found.

' + $allNsxtTransportNodeTunnelStatusObject } - $allNsxtTransportNodeTunnelStatusObject } } } @@ -2454,6 +2509,12 @@ Function Publish-NsxtTier0BgpStatus { .EXAMPLE Publish-NsxtTier0BgpStatus -server sfo-vcf01.sfo.rainpole.io -user admin@local -pass VMw@re1!VMw@re1! -workloadDomain sfo-w01 This example will publish the BGP status for the NSX Tier-0 gateways in a VMware Cloud Foundation instance for a workload domain names sfo-w01. + + .EXAMPLE + Publish-NsxtTier0BgpStatus -server sfo-vcf01.sfo.rainpole.io -user admin@local -pass VMw@re1!VMw@re1! -allDomains -outputJson F:\Reporting + This example will generate a json for the BGP status for all NSX Tier-0 gateways in a VMware Cloud Foundation instance. + and saves it under F:\Reporting with filename -nsxttier0bgp-status.json + #> Param ( [Parameter (Mandatory = $true)] [ValidateNotNullOrEmpty()] [String]$server, @@ -2461,7 +2522,8 @@ Function Publish-NsxtTier0BgpStatus { [Parameter (Mandatory = $true)] [ValidateNotNullOrEmpty()] [String]$pass, [Parameter (ParameterSetName = 'All-WorkloadDomains', Mandatory = $true)] [ValidateNotNullOrEmpty()] [Switch]$allDomains, [Parameter (ParameterSetName = 'Specific-WorkloadDomain', Mandatory = $true)] [ValidateNotNullOrEmpty()] [String]$workloadDomain, - [Parameter (Mandatory = $false)] [ValidateNotNullOrEmpty()] [Switch]$failureOnly + [Parameter (Mandatory = $false)] [ValidateNotNullOrEmpty()] [Switch]$failureOnly, + [Parameter (Mandatory = $false)] [ValidateNotNullOrEmpty()] $outputJson ) Try { @@ -2486,19 +2548,24 @@ Function Publish-NsxtTier0BgpStatus { $nsxtTier0BgpStatus = Request-NsxtTier0BgpStatus -server $server -user $user -pass $pass -domain $workloadDomain; $allNsxtTier0BgpStatusObject += $nsxtTier0BgpStatus } } - - if ($allNsxtTier0BgpStatusObject.Count -eq 0) { $addNoIssues = $true } - if ($nsxtTier0BgpStatus.Count -gt 0) { - if ($addNoIssues) { - $allNsxtTier0BgpStatusObject = $allNsxtTier0BgpStatusObject | Sort-Object 'NSX Manager', 'Domain', 'Tier-0 ID', 'Source Address' | ConvertTo-Html -Fragment -PreContent '

NSX Tier-0 Gateway BGP Status

' -PostContent '

No issues found.

' + if ($PsBoundParameters.ContainsKey('outputJson')) { + $json = Start-CreateOutputJsonDirectory -jsonFolder $outputJson -jsonFileSuffix $nsxttier0bgpJsonSuffix + $allNsxtTier0BgpStatusObject | ConvertTo-JSON -Depth 10 | Out-File $json + Write-Output "JSON Created at $json" + } else { + if ($allNsxtTier0BgpStatusObject.Count -eq 0) { $addNoIssues = $true } + if ($nsxtTier0BgpStatus.Count -gt 0) { + if ($addNoIssues) { + $allNsxtTier0BgpStatusObject = $allNsxtTier0BgpStatusObject | Sort-Object 'NSX Manager', 'Domain', 'Tier-0 ID', 'Source Address' | ConvertTo-Html -Fragment -PreContent '

NSX Tier-0 Gateway BGP Status

' -PostContent '

No issues found.

' + } else { + $allNsxtTier0BgpStatusObject = $allNsxtTier0BgpStatusObject | Sort-Object 'NSX Manager', 'Domain', 'Tier-0 ID', 'Source Address' | ConvertTo-Html -Fragment -PreContent '

NSX Tier-0 Gateway BGP Status

' -As Table + } + $allNsxtTier0BgpStatusObject = Convert-CssClass -htmldata $allNsxtTier0BgpStatusObject } else { - $allNsxtTier0BgpStatusObject = $allNsxtTier0BgpStatusObject | Sort-Object 'NSX Manager', 'Domain', 'Tier-0 ID', 'Source Address' | ConvertTo-Html -Fragment -PreContent '

NSX Tier-0 Gateway BGP Status

' -As Table + $allNsxtTier0BgpStatusObject = $allNsxtTier0BgpStatusObject | ConvertTo-Html -Fragment -PreContent '

NSX Tier-0 Gateway BGP Status

' -PostContent '

No BGP configuration found on NSX Tier-0 Gateway(s).

' -As Table } - $allNsxtTier0BgpStatusObject = Convert-CssClass -htmldata $allNsxtTier0BgpStatusObject - } else { - $allNsxtTier0BgpStatusObject = $allNsxtTier0BgpStatusObject | ConvertTo-Html -Fragment -PreContent '

NSX Tier-0 Gateway BGP Status

' -PostContent '

No BGP configuration found on NSX Tier-0 Gateway(s).

' -As Table + $allNsxtTier0BgpStatusObject } - $allNsxtTier0BgpStatusObject } } } @@ -2536,6 +2603,12 @@ Function Publish-SnapshotStatus { .EXAMPLE Publish-SnapshotStatus -server sfo-vcf01.sfo.rainpole.io -user admin@local -pass VMw@re1!VMw@re1! -workloadDomain sfo-w01 This example will publish the snapshot status for the SDDC Manager, vCenter Server instance, and NSX Edge nodes managed by SDDC Manager for a workload domain names sfo-w01. + + .EXAMPLE + Publish-SnapshotStatus -server sfo-vcf01.sfo.rainpole.io -user admin@local -pass VMw@re1!VMw@re1! -allDomains -outputJson F:\Reporting + This example will generate a json for the snapshot status for the SDDC Manager, vCenter Server instances, and NSX Edge nodes managed by SDDC Manager. + and saves it under F:\Reporting with filename -snapshot-status.json + #> Param ( @@ -2544,7 +2617,9 @@ Function Publish-SnapshotStatus { [Parameter (Mandatory = $true)] [ValidateNotNullOrEmpty()] [String]$pass, [Parameter (ParameterSetName = 'All-WorkloadDomains', Mandatory = $true)] [ValidateNotNullOrEmpty()] [Switch]$allDomains, [Parameter (ParameterSetName = 'Specific-WorkloadDomains', Mandatory = $true)] [ValidateNotNullOrEmpty()] [String]$workloadDomain, - [Parameter (Mandatory = $false)] [ValidateNotNullOrEmpty()] [Switch]$failureOnly + [Parameter (Mandatory = $false)] [ValidateNotNullOrEmpty()] [Switch]$failureOnly, + [Parameter (Mandatory = $false)] [ValidateNotNullOrEmpty()] $outputJson + ) Try { @@ -2583,14 +2658,21 @@ Function Publish-SnapshotStatus { } } - if ($allSnapshotStatusObject.Count -eq 0) { $addNoIssues = $true } - if ($addNoIssues) { - $allSnapshotStatusObject = $allSnapshotStatusObject | Sort-Object Component, Resource, Element | ConvertTo-Html -Fragment -PreContent '

Snapshot Status

' -PostContent '

No issues found.

' + if ($PsBoundParameters.ContainsKey('outputJson')) { + $json = Start-CreateOutputJsonDirectory -jsonFolder $outputJson -jsonFileSuffix $snapshotJsonSuffix + $allSnapshotStatusObject | ConvertTo-JSON -Depth 10 | Out-File $json + Write-Output "JSON Created at $json" } else { - $allSnapshotStatusObject = $allSnapshotStatusObject | Sort-Object Component, Resource, Element | ConvertTo-Html -Fragment -PreContent '

Snapshot Status

' -PostContent '

Only checks snapshots for SDDC Manager, vCenter Server instances, and NSX Edge nodes managed by SDDC Manager. By default, snapshots for NSX Local Manager cluster appliances are disabled and are not recommended.

' -As Table + + if ($allSnapshotStatusObject.Count -eq 0) { $addNoIssues = $true } + if ($addNoIssues) { + $allSnapshotStatusObject = $allSnapshotStatusObject | Sort-Object Component, Resource, Element | ConvertTo-Html -Fragment -PreContent '

Snapshot Status

' -PostContent '

No issues found.

' + } else { + $allSnapshotStatusObject = $allSnapshotStatusObject | Sort-Object Component, Resource, Element | ConvertTo-Html -Fragment -PreContent '

Snapshot Status

' -PostContent '

Only checks snapshots for SDDC Manager, vCenter Server instances, and NSX Edge nodes managed by SDDC Manager. By default, snapshots for NSX Local Manager cluster appliances are disabled and are not recommended.

' -As Table + } + $allSnapshotStatusObject = Convert-CssClass -htmldata $allSnapshotStatusObject + $allSnapshotStatusObject } - $allSnapshotStatusObject = Convert-CssClass -htmldata $allSnapshotStatusObject - $allSnapshotStatusObject } } } @@ -2623,6 +2705,12 @@ Function Publish-LocalUserExpiry { .EXAMPLE Publish-LocalUserExpiry -server sfo-vcf01.sfo.rainpole.io -user admin@local -pass VMw@re1!VMw@re1! -sddcRootPass VMw@re1! -allDomains -failureOnly This example checks the expiry for local OS users for all Workload Domains across the VMware Cloud Foundation instance but only reports issues. + + .EXAMPLE + Publish-LocalUserExpiry -server sfo-vcf01.sfo.rainpole.io -user admin@local -pass VMw@re1!VMw@re1! -sddcRootPass VMw@re1! -allDomains -outputJson F:\Reporting + This example checks the expiry for local OS users for all Workload Domains across the VMware Cloud Foundation + and saves it under F:\Reporting with filename -localuserexpiry-status.json + #> Param ( @@ -2632,7 +2720,8 @@ Function Publish-LocalUserExpiry { [Parameter (Mandatory = $true)] [ValidateNotNullOrEmpty()] [String]$sddcRootPass, [Parameter (ParameterSetName = 'All-WorkloadDomains', Mandatory = $true)] [ValidateNotNullOrEmpty()] [Switch]$allDomains, [Parameter (ParameterSetName = 'Specific-WorkloadDomains', Mandatory = $true)] [ValidateNotNullOrEmpty()] [String]$workloadDomain, - [Parameter (Mandatory = $false)] [ValidateNotNullOrEmpty()] [Switch]$failureOnly + [Parameter (Mandatory = $false)] [ValidateNotNullOrEmpty()] [Switch]$failureOnly, + [Parameter (Mandatory = $false)] [ValidateNotNullOrEmpty()] $outputJson ) Try { @@ -2678,15 +2767,22 @@ Function Publish-LocalUserExpiry { $nsxtEdgePasswordExpiry = Request-NsxtEdgeUserExpiry -server $server -user $user -pass $pass -domain $workloadDomain; $allPasswordExpiryObject += $nsxtEdgePasswordExpiry } } - - if ($allPasswordExpiryObject.Count -eq 0) { $addNoIssues = $true } - if ($addNoIssues) { - $allPasswordExpiryObject = $allPasswordExpiryObject | Sort-Object Resource, Component | ConvertTo-Html -Fragment -PreContent '

Password Expiry Health Status

' -PostContent '

No issues found.

' + if ($PsBoundParameters.ContainsKey('outputJson')) { + $json = Start-CreateOutputJsonDirectory -jsonFolder $outputJson -jsonFileSuffix $localuserexpiryJsonSuffix + Write-Output $json + Write-Output $$allPasswordExpiryObject + $allPasswordExpiryObject | ConvertTo-JSON -Depth 10 | Out-File $json + Write-Output "JSON Created at $json" } else { - $allPasswordExpiryObject = $allPasswordExpiryObject | Sort-Object Resource, Component | ConvertTo-Html -Fragment -PreContent '

Password Expiry Health Status

' -As Table + if ($allPasswordExpiryObject.Count -eq 0) { $addNoIssues = $true } + if ($addNoIssues) { + $allPasswordExpiryObject = $allPasswordExpiryObject | Sort-Object Resource, Component | ConvertTo-Html -Fragment -PreContent '

Password Expiry Health Status

' -PostContent '

No issues found.

' + } else { + $allPasswordExpiryObject = $allPasswordExpiryObject | Sort-Object Resource, Component | ConvertTo-Html -Fragment -PreContent '

Password Expiry Health Status

' -As Table + } + $allPasswordExpiryObject = Convert-CssClass -htmldata $allPasswordExpiryObject + $allPasswordExpiryObject } - $allPasswordExpiryObject = Convert-CssClass -htmldata $allPasswordExpiryObject - $allPasswordExpiryObject } Catch { Debug-CatchWriter -object $_ @@ -2694,6 +2790,95 @@ Function Publish-LocalUserExpiry { } Export-ModuleMember -Function Publish-LocalUserExpiry +Function Publish-NsxtHealthNonSOS { + + <# + .SYNOPSIS + Publish NSX Manager Health only for health checks which are not a part of SOS Utility NSX health. Data obtained is a subset of Publish-NsxtCombinedHealth cmdlet. + + .DESCRIPTION + The Publish-NsxtHealthNonSOS cmdlet performs additional checks outside of SOS Utility to get the health of NSX Manager on the VMware Cloud Foundation instance + and prepares the data to be published to an HTML report. Data obtained is subset of Publish-NsxtCombinedHealth cmdlet. The cmdlet connects to SDDC Manager using the + -server, -user, and password values: + - Validates that network connectivity and autehentication is available to SDDC Manager + - Validates that network connectivity and autehentication is available to NSX Manager + - Performs health checks and outputs the results + + .EXAMPLE + Publish-NsxtHealthNonSOS -server sfo-vcf01.sfo.rainpole.io -user admin@local -pass VMw@re1!VMw@re1! -allDomains + This example checks NSX Manager health outside SOS Utility for all Workload Domains across the VMware Cloud Foundation instance. + + .EXAMPLE + Publish-NsxtHealthNonSOS -server sfo-vcf01.sfo.rainpole.io -user admin@local -pass VMw@re1!VMw@re1! -workloadDomain sfo-w01 + This example checks NSX Manager health outside SOS Utility for a single Workload Domain in a VMware Cloud Foundation instance. + + .EXAMPLE + Publish-NsxtHealthNonSOS -server sfo-vcf01.sfo.rainpole.io -user admin@local -pass VMw@re1!VMw@re1! -allDomains -failureOnly + This example checks NSX Manager health outside SOS Utility for all Workload Domains across the VMware Cloud Foundation instance but only reports issues. + + .EXAMPLE + Publish-NsxtHealthNonSOS -server sfo-vcf01.sfo.rainpole.io -user admin@local -pass VMw@re1!VMw@re1! -allDomains -outputJson F:\Reporting + This example checks NSX Manager health outside SOS Utility for all Workload Domains across the VMware Cloud Foundation instance and + and saves it as JSON under F:\Reporting with filename -nsxtcombinedhealthnonsos-status.json + + #> + + Param ( + [Parameter (Mandatory = $true)] [ValidateNotNullOrEmpty()] [String]$server, + [Parameter (Mandatory = $true)] [ValidateNotNullOrEmpty()] [String]$user, + [Parameter (Mandatory = $true)] [ValidateNotNullOrEmpty()] [String]$pass, + [Parameter (ParameterSetName = 'All-WorkloadDomains', Mandatory = $true)] [ValidateNotNullOrEmpty()] [Switch]$allDomains, + [Parameter (ParameterSetName = 'Specific-WorkloadDomain', Mandatory = $true)] [ValidateNotNullOrEmpty()] [String]$workloadDomain, + [Parameter (Mandatory = $false)] [ValidateNotNullOrEmpty()] [Switch]$failureOnly, + [Parameter (Mandatory = $false)] [ValidateNotNullOrEmpty()] $outputJson + ) + + Try { + $allNsxtHealthObject = New-Object System.Collections.ArrayList + $allWorkloadDomains = Get-VCFWorkloadDomain + if ($PsBoundParameters.ContainsKey("allDomains") -and $PsBoundParameters.ContainsKey("failureOnly")) { + foreach ($domain in $allWorkloadDomains ) { + $nsxtVidmStatus = Request-NsxtVidmStatus -server $server -user $user -pass $pass -domain $domain.name -failureOnly; $allNsxtHealthObject += $nsxtVidmStatus + $nsxtComputeManagerStatus = Request-NsxtComputeManagerStatus -server $server -user $user -pass $pass -domain $domain.name -failureOnly; $allNsxtHealthObject += $nsxtComputeManagerStatus + } + } elseif ($PsBoundParameters.ContainsKey("allDomains")) { + foreach ($domain in $allWorkloadDomains ) { + $nsxtVidmStatus = Request-NsxtVidmStatus -server $server -user $user -pass $pass -domain $domain.name; $allNsxtHealthObject += $nsxtVidmStatus + $nsxtComputeManagerStatus = Request-NsxtComputeManagerStatus -server $server -user $user -pass $pass -domain $domain.name; $allNsxtHealthObject += $nsxtComputeManagerStatus + } + } + + if ($PsBoundParameters.ContainsKey("workloadDomain") -and $PsBoundParameters.ContainsKey("failureOnly")) { + $nsxtVidmStatus = Request-NsxtVidmStatus -server $server -user $user -pass $pass -domain $workloadDomain -failureOnly; $allNsxtHealthObject += $nsxtVidmStatus + $nsxtComputeManagerStatus = Request-NsxtComputeManagerStatus -server $server -user $user -pass $pass -domain $workloadDomain -failureOnly; $allNsxtHealthObject += $nsxtComputeManagerStatus + } elseif ($PsBoundParameters.ContainsKey("workloadDomain")) { + $nsxtVidmStatus = Request-NsxtVidmStatus -server $server -user $user -pass $pass -domain $workloadDomain; $allNsxtHealthObject += $nsxtVidmStatus + $nsxtComputeManagerStatus = Request-NsxtComputeManagerStatus -server $server -user $user -pass $pass -domain $workloadDomain; $allNsxtHealthObject += $nsxtComputeManagerStatus + } + + if ($PsBoundParameters.ContainsKey("outputJson")) { + $json = Start-CreateOutputJsonDirectory -jsonFolder $outputJson -jsonFileSuffix $nsxtCombinedHealthNonSOSJsonSuffix + $allNsxtHealthObject | ConvertTo-JSON -Depth 10 | Out-File $json + Write-Output "JSON Created at $json" + } else { + if ($allNsxtHealthObject.Count -eq 0) { $addNoIssues = $true } + if ($addNoIssues) { + $allNsxtHealthObject = $allNsxtHealthObject | Sort-Object Component, Resource | ConvertTo-Html -Fragment -PreContent '

NSX Manager Health Status - Non SOS

' -PostContent '

No issues found.

' + } else { + $allNsxtHealthObject = $allNsxtHealthObject | Sort-Object Component, Resource | ConvertTo-Html -Fragment -PreContent '

NSX Manager Health Status - Non SOS

' -As Table + } + $allNsxtHealthObject = Convert-CssClass -htmldata $allNsxtHealthObject + $allNsxtHealthObject + } + + } + Catch { + Debug-CatchWriter -object $_ + } +} +Export-ModuleMember -Function Publish-NsxtHealthNonSOS + + Function Publish-NsxtCombinedHealth { <# .SYNOPSIS @@ -2718,6 +2903,7 @@ Function Publish-NsxtCombinedHealth { .EXAMPLE Publish-NsxtCombinedHealth -server sfo-vcf01.sfo.rainpole.io -user admin@local -pass VMw@re1!VMw@re1! -json -allDomains -failureOnly This example checks NSX Manager health for all Workload Domains across the VMware Cloud Foundation instance but only reports issues. + #> Param ( @@ -2757,6 +2943,7 @@ Function Publish-NsxtCombinedHealth { $nsxtHtml = Publish-NsxtHealth -json $json; $allNsxtHealthObject += $nsxtHtml } + if ($allNsxtHealthObject.Count -eq 0) { $addNoIssues = $true } if ($addNoIssues) { $allNsxtHealthObject = $allNsxtHealthObject | Sort-Object Component, Resource | ConvertTo-Html -Fragment -PreContent '

NSX Manager Health Status

' -PostContent '

No issues found.

' @@ -2765,6 +2952,7 @@ Function Publish-NsxtCombinedHealth { } $allNsxtHealthObject = Convert-CssClass -htmldata $allNsxtHealthObject $allNsxtHealthObject + } Catch { Debug-CatchWriter -object $_ @@ -2795,6 +2983,12 @@ Function Publish-StorageCapacityHealth { .EXAMPLE Publish-StorageCapacityHealth -server sfo-vcf01.sfo.rainpole.io -user admin@local -pass VMw@re1!VMw@re1! -rootPass VMw@re1! -workloadDomain sfo-w01 This example will publish storage usage status for a specific Workload Domain in a VMware Cloud Foundation instance + + .EXAMPLE + Publish-StorageCapacityHealth -server sfo-vcf01.sfo.rainpole.io -user admin@local -pass VMw@re1!VMw@re1! -rootPass VMw@re1! -workloadDomain sfo-w01 -outputJson F:\Reporting + This example will publish storage usage status for a specific Workload Domain in a VMware Cloud Foundation instance + and saves it as JSON under F:\Reporting with filename -storagecapacityhealth-status.json + #> Param ( @@ -2804,68 +2998,105 @@ Function Publish-StorageCapacityHealth { [Parameter (Mandatory = $true)] [ValidateNotNullOrEmpty()] [String]$rootPass, [Parameter (ParameterSetName = 'All-WorkloadDomains', Mandatory = $true)] [ValidateNotNullOrEmpty()] [Switch]$allDomains, [Parameter (ParameterSetName = 'Specific-WorkloadDomain', Mandatory = $true)] [ValidateNotNullOrEmpty()] [String]$workloadDomain, - [Parameter (Mandatory = $false)] [ValidateNotNullOrEmpty()] [Switch]$failureOnly + [Parameter (Mandatory = $false)] [ValidateNotNullOrEmpty()] [Switch]$failureOnly, + [Parameter (Mandatory = $false)] [ValidateNotNullOrEmpty()] $outputJson ) Try { if (Test-VCFConnection -server $server) { if (Test-VCFAuthentication -server $server -user $user -pass $pass) { + $allWorkloadDomains = Get-VCFWorkloadDomain + $singleWorkloadDomain = Get-VCFWorkloadDomain | Where-Object {$_.name -eq $workloadDomain} $allStorageCapacityHealth = New-Object System.Collections.ArrayList - if ($PsBoundParameters.ContainsKey('failureOnly')) { $failureOnlySwitch = "-failureOnly" } if ($PsBoundParameters.ContainsKey("allDomains")) { - $allWorkloadDomains = Get-VCFWorkloadDomain - $sddcManagerStorageHealth = Invoke-Expression "Request-SddcManagerStorageHealth -server $server -user $user -pass $pass -rootPass $rootPass $($failureOnlySwitch)" - foreach ($domain in $allWorkloadDomains ) { - $vCenterStorageHealth = Invoke-Expression "Request-VcenterStorageHealth -server $server -user $user -pass $pass -domain $($domain.name) $($failureOnlySwitch)"; $allVcenterStorageHealth += $vCenterStorageHealth - $esxiStorageCapacity = Invoke-Expression "Request-EsxiStorageCapacity -server $server -user $user -pass $pass -domain $($domain.name) $($failureOnlySwitch)"; $allEsxiStorageCapacity += $esxiStorageCapacity - $datastoreStorageCapacity = Invoke-Expression "Request-DatastoreStorageCapacity -server $server -user $user -pass $pass -domain $($domain.name) $($failureOnlySwitch)"; $allDatastoreStorageCapacity += $datastoreStorageCapacity + if ($PsBoundParameters.ContainsKey("failureOnly")) { + $sddcManagerStorageHealth = Request-SddcManagerStorageHealth -server $server -user $user -pass $pass -rootPass $rootPass -failureOnly; + foreach ($domain in $allWorkloadDomains ) { + $vCenterStorageHealth = Request-VcenterStorageHealth -server $server -user $user -pass $pass -domain $domain.name -failureOnly; $allVcenterStorageHealth += $vCenterStorageHealth + $esxiStorageCapacity = Request-EsxiStorageCapacity -server $server -user $user -pass $pass -domain $domain.name -failureOnly; $allEsxiStorageCapacity += $esxiStorageCapacity + $datastoreStorageCapacity = Request-DatastoreStorageCapacity -server $server -user $user -pass $pass -domain $domain.name -failureOnly; $allDatastoreStorageCapacity += $datastoreStorageCapacity + } + } else { + $sddcManagerStorageHealth = Request-SddcManagerStorageHealth -server $server -user $user -pass $pass -rootPass $rootPass + foreach ($domain in $allWorkloadDomains ) { + $vCenterStorageHealth = Request-VcenterStorageHealth -server $server -user $user -pass $pass -domain $domain.name; $allVcenterStorageHealth += $vCenterStorageHealth + $esxiStorageCapacity = Request-EsxiStorageCapacity -server $server -user $user -pass $pass -domain $domain.name; $allEsxiStorageCapacity += $esxiStorageCapacity + $datastoreStorageCapacity = Request-DatastoreStorageCapacity -server $server -user $user -pass $pass -domain $domain.name; $allDatastoreStorageCapacity += $datastoreStorageCapacity + } } - } elseif ($PsBoundParameters.ContainsKey("workloadDomain")) { - $singleWorkloadDomain = Get-VCFWorkloadDomain | Where-Object {$_.name -eq $workloadDomain} - if ($singleWorkloadDomain.type -eq "MANAGEMENT") { - $sddcManagerStorageHealth = Invoke-Expression "Request-SddcManagerStorageHealth -server $server -user $user -pass $pass -rootPass $rootPass $($failureOnlySwitch)" + } else { + if ($PsBoundParameters.ContainsKey("failureOnly")) { + if ($singleWorkloadDomain.type -eq "MANAGEMENT") { + $sddcManagerStorageHealth = Request-SddcManagerStorageHealth -server $server -user $user -pass $pass -rootPass $rootPass -failureOnly + } + $vCenterStorageHealth = Request-VcenterStorageHealth -server $server -user $user -pass $pass -domain $workloadDomain -failureOnly; $allVcenterStorageHealth += $vCenterStorageHealth + $esxiStorageCapacity = Request-EsxiStorageCapacity -server $server -user $user -pass $pass -domain $workloadDomain -failureOnly; $allEsxiStorageCapacity += $esxiStorageCapacity + $datastoreStorageCapacity = Request-DatastoreStorageCapacity -server $server -user $user -pass $pass -domain $workloadDomain -failureOnly; $allDatastoreStorageCapacity += $datastoreStorageCapacity + } else { + if ($singleWorkloadDomain.type -eq "MANAGEMENT") { + $sddcManagerStorageHealth = Request-SddcManagerStorageHealth -server $server -user $user -pass $pass -rootPass $rootPass + } + $vCenterStorageHealth = Request-VcenterStorageHealth -server $server -user $user -pass $pass -domain $workloadDomain; $allVcenterStorageHealth += $vCenterStorageHealth + $esxiStorageCapacity = Request-EsxiStorageCapacity -server $server -user $user -pass $pass -domain $workloadDomain; $allEsxiStorageCapacity += $esxiStorageCapacity + $datastoreStorageCapacity = Request-DatastoreStorageCapacity -server $server -user $user -pass $pass -domain $workloadDomain; $allDatastoreStorageCapacity += $datastoreStorageCapacity } - $vCenterStorageHealth = Invoke-Expression "Request-VcenterStorageHealth -server $server -user $user -pass $pass -domain $workloadDomain $($failureOnlySwitch)"; $allVcenterStorageHealth += $vCenterStorageHealth - $esxiStorageCapacity = Invoke-Expression "Request-EsxiStorageCapacity -server $server -user $user -pass $pass -domain $workloadDomain $($failureOnlySwitch)"; $allEsxiStorageCapacity += $esxiStorageCapacity - $datastoreStorageCapacity = Invoke-Expression "Request-DatastoreStorageCapacity -server $server -user $user -pass $pass -domain $workloadDomain $($failureOnlySwitch)"; $allDatastoreStorageCapacity += $datastoreStorageCapacity } - if ($sddcManagerStorageHealth.Count -eq 0) { $addNoIssues = $true } - if ($addNoIssues) { - $sddcManagerStorageHealth = $sddcManagerStorageHealth | ConvertTo-Html -Fragment -PreContent '

SDDC Manager Disk Health Status

' -PostContent '

No Issues Found.

' - } else { - $sddcManagerStorageHealth = $sddcManagerStorageHealth | ConvertTo-Html -Fragment -PreContent '

SDDC Manager Disk Health Status

' -As Table - } - $sddcManagerStorageHealth = Convert-CssClass -htmldata $sddcManagerStorageHealth; $allStorageCapacityHealth += $sddcManagerStorageHealth + if ($PsBoundParameters.ContainsKey('outputJson')) { + $json = Start-CreateOutputJsonDirectory -jsonFolder $outputJson -jsonFileSuffix $storageCapacityHealthJsonSuffix + $combinedjson = @{ + "sddc-manager" = $sddcManagerStorageHealth + "vcenter" = $allVcenterStorageHealth + "esxi" = $allEsxiStorageCapacity + "datastore" = $allDatastoreStorageCapacity + } + $combinedJson | ConvertTo-JSON -Depth 10 | Out-File $json + Write-Output "JSON Created at $json" - if ($allVcenterStorageHealth.Count -eq 0) { $addNoIssues = $true } - if ($addNoIssues) { - $allVcenterStorageHealth = $allVcenterStorageHealth | Sort-Object FQDN, Filesystem | ConvertTo-Html -Fragment -PreContent '

vCenter Server Disk Health

' -PostContent '

No Issues Found.

' } else { - $allVcenterStorageHealth = $allVcenterStorageHealth | Sort-Object FQDN, Filesystem | ConvertTo-Html -Fragment -PreContent '

vCenter Server Disk Health

' -As Table - } - $allVcenterStorageHealth = Convert-CssClass -htmldata $allVcenterStorageHealth; $allStorageCapacityHealth += $allVcenterStorageHealth + if ($sddcManagerStorageHealth.Count -eq 0) { $addNoIssues = $true } + if ($addNoIssues) { + $sddcManagerStorageHealth = $sddcManagerStorageHealth | ConvertTo-Html -Fragment -PreContent '

SDDC Manager Disk Health Status

' -PostContent '

No Issues Found.

' + } else { + $sddcManagerStorageHealth = $sddcManagerStorageHealth | ConvertTo-Html -Fragment -PreContent '

SDDC Manager Disk Health Status

' -As Table + } + $sddcManagerStorageHealth = Convert-CssClass -htmldata $sddcManagerStorageHealth - if ($allEsxiStorageCapacity.Count -eq 0) { $addNoIssues = $true } - if ($addNoIssues) { - $allEsxiStorageCapacity = $allEsxiStorageCapacity | Sort-Object Domain, 'ESXi FQDN', 'Volume Name' | ConvertTo-Html -Fragment -PreContent '

ESXi Host Local Volume Capacity

' -PostContent '

No Issues Found.

' - } else { - $allEsxiStorageCapacity = $allEsxiStorageCapacity | Sort-Object Domain, 'ESXi FQDN', 'Volume Name' | ConvertTo-Html -Fragment -PreContent '

ESXi Host Local Volume Capacity

' -As Table - } - $allEsxiStorageCapacity = Convert-CssClass -htmldata $allEsxiStorageCapacity; $allStorageCapacityHealth += $allEsxiStorageCapacity + if ($allVcenterStorageHealth.Count -eq 0) { $addNoIssues = $true } + if ($addNoIssues) { + $allVcenterStorageHealth = $allVcenterStorageHealth | Sort-Object FQDN, Filesystem | ConvertTo-Html -Fragment -PreContent '

vCenter Server Disk Health

' -PostContent '

No Issues Found.

' + } else { + $allVcenterStorageHealth = $allVcenterStorageHealth | Sort-Object FQDN, Filesystem | ConvertTo-Html -Fragment -PreContent '

vCenter Server Disk Health

' -As Table + } + $allVcenterStorageHealth = Convert-CssClass -htmldata $allVcenterStorageHealth - if ($allDatastoreStorageCapacity.Count -eq 0) { $addNoIssues = $true } - if ($addNoIssues) { - $allDatastoreStorageCapacity = $allDatastoreStorageCapacity | Sort-Object 'vCenter Server', 'Datastore Name' | ConvertTo-Html -Fragment -PreContent '

Datastore Space Usage Report

' -PostContent '

No Issues Found.

' - } else { - $allDatastoreStorageCapacity = $allDatastoreStorageCapacity | Sort-Object 'vCenter Server', 'Datastore Name' | ConvertTo-Html -Fragment -PreContent '

Datastore Space Usage Report

' -As Table + if ($allEsxiStorageCapacity.Count -eq 0) { $addNoIssues = $true } + if ($addNoIssues) { + $allEsxiStorageCapacity = $allEsxiStorageCapacity | Sort-Object Domain, 'ESXi FQDN', 'Volume Name' | ConvertTo-Html -Fragment -PreContent '

ESXi Host Local Volume Capacity

' -PostContent '

No Issues Found.

' + } else { + $allEsxiStorageCapacity = $allEsxiStorageCapacity | Sort-Object Domain, 'ESXi FQDN', 'Volume Name' | ConvertTo-Html -Fragment -PreContent '

ESXi Host Local Volume Capacity

' -As Table + } + $allEsxiStorageCapacity = Convert-CssClass -htmldata $allEsxiStorageCapacity + + if ($allDatastoreStorageCapacity.Count -eq 0) { $addNoIssues = $true } + if ($addNoIssues) { + $allDatastoreStorageCapacity = $allDatastoreStorageCapacity | Sort-Object 'vCenter Server', 'Datastore Name' | ConvertTo-Html -Fragment -PreContent '

Datastore Space Usage Report

' -PostContent '

No Issues Found.

' + } else { + $allDatastoreStorageCapacity = $allDatastoreStorageCapacity | Sort-Object 'vCenter Server', 'Datastore Name' | ConvertTo-Html -Fragment -PreContent '

Datastore Space Usage Report

' -As Table + } + $allDatastoreStorageCapacity = Convert-CssClass -htmldata $allDatastoreStorageCapacity + + $allStorageCapacityHealth += $sddcManagerStorageHealth + $allStorageCapacityHealth += $allVcenterStorageHealth + $allStorageCapacityHealth += $allEsxiStorageCapacity + $allStorageCapacityHealth += $allDatastoreStorageCapacity + $allStorageCapacityHealth } - $allDatastoreStorageCapacity = Convert-CssClass -htmldata $allDatastoreStorageCapacity; $allStorageCapacityHealth += $allDatastoreStorageCapacity - $allStorageCapacityHealth } } - } Catch { + } + Catch { Debug-CatchWriter -object $_ } } @@ -4498,6 +4729,88 @@ Function Request-EsxiStorageCapacity { } Export-ModuleMember -Function Request-EsxiStorageCapacity +Function Publish-ComponentConnectivityHealthNonSOS { + <# + .SYNOPSIS + Request and publish Component Connectivity Health only for health checks which are not a part of SOS Utility NSX health. + Data obtained is a subset of Publish-ComponentConnectivityHealth cmdlet. + + .DESCRIPTION + The Publish-ComponentConnectivityHealthNonSOS cmdlet checks component connectivity across the VMware Cloud Foundation + instance and prepares the data to be published to an HTML report. The cmdlet connects to SDDC Manager using the + -server, -user, and password values: + - Validates that network connectivity is available to the SDDC Manager instance + - Performs connectivityy health checks and outputs the results + + .EXAMPLE + Publish-ComponentConnectivityHealthNonSOS -server sfo-vcf01.sfo.rainpole.io -user admin@local -pass VMw@re1!VMw@re1! -allDomains + This example checks the component connectivity outside of SOS utility for all Workload Domains across the VMware Cloud Foundation instance. + + .EXAMPLE + Publish-ComponentConnectivityHealthNonSOS -server sfo-vcf01.sfo.rainpole.io -user admin@local -pass VMw@re1!VMw@re1! -workloadDomain sfo-w01 + This example checks the component connectivity outside of SOS utility for a single Workload Domain in a VMware Cloud Foundation instance. + + .EXAMPLE + Publish-ComponentConnectivityHealthNonSOS -server sfo-vcf01.sfo.rainpole.io -user admin@local -pass VMw@re1!VMw@re1! -allDomains -failureOnly + This example checks the component connectivity outside of SOS utility for all Workload Domains across the VMware Cloud Foundation instance but only reports issues. + + .EXAMPLE + Publish-ComponentConnectivityHealthNonSOS -server sfo-vcf01.sfo.rainpole.io -user admin@local -pass VMw@re1!VMw@re1! -allDomains -jsonOutput F:\Reporting + This example checks the component connectivity outside of SOS utility for all Workload Domains across the VMware Cloud Foundation instance + and saves it under F:\Reporting with filename -componentconnectivityhealthnonsos-status.json + #> + + Param ( + [Parameter (Mandatory = $true)] [ValidateNotNullOrEmpty()] [String]$server, + [Parameter (Mandatory = $true)] [ValidateNotNullOrEmpty()] [String]$user, + [Parameter (Mandatory = $true)] [ValidateNotNullOrEmpty()] [String]$pass, + [Parameter (ParameterSetName = 'All-WorkloadDomains', Mandatory = $true)] [ValidateNotNullOrEmpty()] [Switch]$allDomains, + [Parameter (ParameterSetName = 'Specific-WorkloadDomain', Mandatory = $true)] [ValidateNotNullOrEmpty()] [String]$workloadDomain, + [Parameter (Mandatory = $false)] [ValidateNotNullOrEmpty()] [Switch]$failureOnly, + [Parameter (Mandatory = $false)] [ValidateNotNullOrEmpty()] $outputJson + ) + + Try { + $allConnectivityObject = New-Object System.Collections.ArrayList + if ($PsBoundParameters.ContainsKey('failureOnly')) { + if ($PsBoundParameters.ContainsKey("allDomains")) { + $vcenterConnectivity = Request-VcenterAuthentication -server $server -user $user -pass $pass -alldomains -failureOnly; $allConnectivityObject += $vcenterConnectivity + $NsxtConnectivity = Request-NsxtAuthentication -server $server -user $user -pass $pass -alldomains -failureOnly; $allConnectivityObject += $NsxtConnectivity + } else { + $vcenterConnectivity = Request-VcenterAuthentication -server $server -user $user -pass $pass -workloadDomain $workloadDomain -failureOnly; $allConnectivityObject += $vcenterConnectivity + $NsxtConnectivity = Request-NsxtAuthentication -server $server -user $user -pass $pass -workloadDomain $workloadDomain -failureOnly; $allConnectivityObject += $NsxtConnectivity + } + } else { + if ($PsBoundParameters.ContainsKey("allDomains")) { + $vcenterConnectivity = Request-VcenterAuthentication -server $server -user $user -pass $pass -alldomains; $allConnectivityObject += $vcenterConnectivity + $NsxtConnectivity = Request-NsxtAuthentication -server $server -user $user -pass $pass -alldomains; $allConnectivityObject += $NsxtConnectivity + } else { + $vcenterConnectivity = Request-VcenterAuthentication -server $server -user $user -pass $pass -workloadDomain $workloadDomain; $allConnectivityObject += $vcenterConnectivity + $NsxtConnectivity = Request-NsxtAuthentication -server $server -user $user -pass $pass -workloadDomain $workloadDomain; $allConnectivityObject += $NsxtConnectivity + } + } + + if ($PsBoundParameters.ContainsKey("outputJson")) { + $json = Start-CreateOutputJsonDirectory -jsonFolder $outputJson -jsonFileSuffix $ComponentConnectivityHealthNonSOSJsonSuffix + $allConnectivityObject | ConvertTo-JSON -Depth 10 | Out-File $json + Write-Output "JSON Created at $json" + } else { + if ($allConnectivityObject.Count -eq 0) { $addNoIssues = $true } + if ($addNoIssues) { + $allConnectivityObject = $allConnectivityObject | Sort-Object Component, Resource | ConvertTo-Html -Fragment -PreContent '

Connectivity Health Status

' -PostContent '

No issues found.

' + } else { + $allConnectivityObject = $allConnectivityObject | Sort-Object Component, Resource | ConvertTo-Html -Fragment -PreContent '

Connectivity Health Status

' -As Table + } + $allConnectivityObject = Convert-CssClass -htmldata $allConnectivityObject + $allConnectivityObject + } + } + Catch { + Debug-CatchWriter -object $_ + } +} +Export-ModuleMember -Function Publish-ComponentConnectivityHealthNonSOS + Function Publish-ComponentConnectivityHealth { <# .SYNOPSIS @@ -7540,7 +7853,7 @@ Function Publish-NsxManagerPasswordExpiration { } } } - + $nsxManagerPasswordExpirationObject = $nsxManagerPasswordExpirationObject | Sort-Object 'Workload Domain', 'Virtual Machine', 'Local User' | ConvertTo-Html -Fragment -PreContent '

NSX Manager - Password Expiration

' -As Table $nsxManagerPasswordExpirationObject = Convert-CssClass -htmldata $nsxManagerPasswordExpirationObject $nsxManagerPasswordExpirationObject @@ -7593,7 +7906,7 @@ Function Publish-NsxManagerPasswordComplexity { $nsxPasswordComplexity = Request-NsxtManagerPasswordComplexity -server $server -user $user -pass $pass -domain $domain.name; $nsxManagerPasswordComplexityObject += $nsxPasswordComplexity } } - + $nsxManagerPasswordComplexityObject = $nsxManagerPasswordComplexityObject | Sort-Object 'Workload Domain', 'Virtual Machine' | ConvertTo-Html -Fragment -PreContent '

NSX Manager - Password Complexity

' -As Table $nsxManagerPasswordComplexityObject = Convert-CssClass -htmldata $nsxManagerPasswordComplexityObject $nsxManagerPasswordComplexityObject @@ -7646,7 +7959,7 @@ Function Publish-NsxManagerAccountLockout { $nsxAccountLockout = Request-NsxtManagerAccountLockout -server $server -user $user -pass $pass -domain $domain.name; $nsxManagerAccountLockoutObject += $nsxAccountLockout } } - + $nsxManagerAccountLockoutObject = $nsxManagerAccountLockoutObject | Sort-Object 'Workload Domain', 'Virtual Machine' | ConvertTo-Html -Fragment -PreContent '

NSX Manager - Account Lockout

' -As Table $nsxManagerAccountLockoutObject = Convert-CssClass -htmldata $nsxManagerAccountLockoutObject $nsxManagerAccountLockoutObject @@ -7718,7 +8031,7 @@ Function Publish-NsxEdgePasswordExpiration { } } } - + $nsxEdgePasswordExpirationObject = $nsxEdgePasswordExpirationObject | Sort-Object 'Workload Domain', 'Virtual Machine', 'Local User' | ConvertTo-Html -Fragment -PreContent '

NSX Edge - Password Expiration

' -As Table $nsxEdgePasswordExpirationObject = Convert-CssClass -htmldata $nsxEdgePasswordExpirationObject $nsxEdgePasswordExpirationObject @@ -7771,7 +8084,7 @@ Function Publish-NsxEdgePasswordComplexity { $nsxEdgePasswordComplexity = Request-NsxtEdgePasswordComplexity -server $server -user $user -pass $pass -domain $domain.name; $nsxEdgePasswordComplexityObject += $nsxEdgePasswordComplexity } } - + $nsxEdgePasswordComplexityObject = $nsxEdgePasswordComplexityObject | Sort-Object 'Workload Domain', 'Virtual Machine', 'Local User' | ConvertTo-Html -Fragment -PreContent '

NSX Edge - Password Complexity

' -As Table $nsxEdgePasswordComplexityObject = Convert-CssClass -htmldata $nsxEdgePasswordComplexityObject $nsxEdgePasswordComplexityObject @@ -7824,7 +8137,7 @@ Function Publish-NsxEdgeAccountLockout { $nsxEdgeAccountLockout = Request-NsxtEdgeAccountLockout -server $server -user $user -pass $pass -domain $domain.name; $nsxEdgeAccountLockoutObject += $nsxEdgeAccountLockout } } - + $nsxEdgeAccountLockoutObject = $nsxEdgeAccountLockoutObject | Sort-Object 'Workload Domain', 'Virtual Machine', 'Local User' | ConvertTo-Html -Fragment -PreContent '

NSX Edge - Account Lockout

' -As Table $nsxEdgeAccountLockoutObject = Convert-CssClass -htmldata $nsxEdgeAccountLockoutObject $nsxEdgeAccountLockoutObject @@ -8669,6 +8982,31 @@ Function Start-CreateReportDirectory { } Export-ModuleMember -Function Start-CreateReportDirectory +Function Start-CreateOutputJsonDirectory { + Param ( + [Parameter (Mandatory = $true)] [ValidateNotNullOrEmpty()] [String]$jsonFolder, + [Parameter (Mandatory = $true)] [ValidateNotNullOrEmpty()] [String]$jsonFileSuffix + ) + + $filetimeStamp = Get-Date -Format "MM-dd-yyyy_hh_mm_ss" + $Global:jsonFolder = $jsonFolder + $jsonName = $filetimeStamp + "-" + $jsonFileSuffix + + if ($PSEdition -eq "Core" -and ($PSVersionTable.OS).Split(' ')[0] -eq "Linux") { + $jsonDestination = ($jsonDestination = ($jsonFolder + "\" + $jsonName)).split('\') -join '/' | Split-Path -NoQualifier + $jsonFolder = ($jsonFolder).split('\') -join '/' | Split-Path -NoQualifier + } else { + $jsonDestination = ($jsonFolder + "\" + $jsonName) + } + + if (!(Test-Path -Path $jsonFolder)) { + New-Item -Path $jsonFolder -ItemType "directory" | Out-Null + } + + $jsonDestination +} + + Function Invoke-SddcCommand { <# .SYNOPSIS @@ -9192,7 +9530,7 @@ Function Get-ClarityReportNavigation {
  • Password Complexity
  • Account Lockout
  • - + +