Private/Checks/VCenter/Test-VcfVcenterVdsVersionCheck.ps1
|
# Copyright (c) 2026 Broadcom. All Rights Reserved. # Broadcom Confidential. The term "Broadcom" refers to Broadcom Inc. # and/or its subsidiaries. # # ============================================================================= # # SOFTWARE LICENSE AGREEMENT # # Copyright (c) CA, Inc. All rights reserved. # # You are hereby granted a non-exclusive, worldwide, royalty-free license # under CA, Inc.'s copyrights to use, copy, modify, and distribute this # software in source code or binary form for use in connection with CA, Inc. # products. # # This copyright notice shall be included in all copies or substantial # portions of the software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS # IN THE SOFTWARE. # # ============================================================================= function Test-VcfVcenterVdsVersionCheck { <# .SYNOPSIS Checks that every distributed virtual switch on every vCenter attached to SDDC Manager is at a version compatible with vCenter Server 9.0. .DESCRIPTION Queries distributed virtual switch (VDS) inventory across all vCenter appliances connected to SDDC Manager using Get-VcfCheckVDSwitchInventory. Evaluates switch versions against the minimum required version (7.0) for vCenter Server 9.0 compatibility: - Pass: All distributed virtual switches are at version 7.0 or higher. - Fail: One or more distributed virtual switches are below version 7.0. - Skipped: No distributed virtual switches are found in the vCenter inventory. Populates a structured Rows table detailing Switch Name, Datacenter, Version, and Compatible. Delegates per-vCenter execution and per-domain outcome packaging to Invoke-VcfCheckPerVCenterCheck. .PARAMETER Context The VcfCheck.Context object. Must already be connected to SDDC Manager. .PARAMETER DisplayName Optional friendly display name for the check result. .OUTPUTS [PSObject[]] Per-vCenter check results generated by Invoke-VcfCheckPerVCenterCheck. #> [CmdletBinding()] [OutputType([PSObject])] Param ( [Parameter(Mandatory = $true)] [PSObject]$Context, [Parameter(Mandatory = $false)] [String]$DisplayName = '' ) $minimumSupportedVersion = [Version]'7.0' return Invoke-VcfCheckPerVCenterCheck -Context $Context -CheckId 'vcenter_vds_version_check' -Area vCenter -DisplayName $DisplayName -Body { param($Context, $VCenterFqdn) $vdSwitches = @(Get-VcfCheckVDSwitchInventory -Server $VCenterFqdn) if ($vdSwitches.Count -eq 0) { return [PSCustomObject]@{ Status = 'Skipped'; Detail = 'No distributed virtual switches found.'; SkipReasonTag = 'no distributed switches'; Rows = @() } } $rows = @($vdSwitches | ForEach-Object { [PSCustomObject]@{ 'Switch Name' = $_.Name Datacenter = $_.Datacenter.Name Version = $_.Version Compatible = ([Version]$_.Version) -ge $minimumSupportedVersion } } | Sort-Object -Property 'Switch Name') $incompatibleRows = @($rows | Where-Object { -not $_.Compatible }) if ($incompatibleRows.Count -gt 0) { $names = ($incompatibleRows | ForEach-Object { "$($_.'Switch Name') ($($_.Version))" }) -join ', ' return [PSCustomObject]@{ Status = 'Fail'; Detail = "Distributed virtual switch(es) below the required version 7.0 for vCenter Server 9.0: $names"; Rows = $rows } } return [PSCustomObject]@{ Status = 'Pass'; Detail = "Checked $($rows.Count) distributed virtual switch(es); all are at version 7.0 or higher and compatible with vCenter Server 9.0."; Rows = $rows } } } |