Private/Checks/VCenter/Test-VcfVcenterCheckProxy.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-VcfVcenterCheckProxy { <# .SYNOPSIS Checks whether outbound proxy settings are enabled on each vCenter appliance attached to SDDC Manager. .DESCRIPTION Queries appliance networking proxy settings across all vCenter appliances using Get-VcfCheckApplianceNetworkingProxy. Evaluates proxy configurations per protocol: - Warning: One or more outbound proxies are enabled. Advises validating proxy health and connectivity before proceeding with upgrades. - Pass: No outbound proxies are enabled across any protocol. Normalizes unset server strings or negative port values to 'N/A' in the structured output table. Delegates execution and per-domain 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 = '' ) return Invoke-VcfCheckPerVCenterCheck -Context $Context -CheckId 'vcenter_check_proxy' -Area vCenter -DisplayName $DisplayName -Body { param($Context, $VCenterFqdn) $proxyConfig = Get-VcfCheckApplianceNetworkingProxy -Server $VCenterFqdn $enabledProxies = [System.Collections.Generic.List[String]]::new() # The vSphere API returns Server = '' and Port = -1 as its "unset" sentinel values # when a protocol has no proxy configured - shown as-is that reads as a real port # number, not "not configured", so blank/-1 are normalized to 'N/A' for display. $rows = @($proxyConfig.Keys | ForEach-Object { $protocol = $_ $protocolConfig = $proxyConfig[$protocol] if ($protocolConfig.Enabled -and $protocolConfig.Server -and $protocolConfig.Port) { $enabledProxies.Add("$protocol`: $($protocolConfig.Server):$($protocolConfig.Port)") } [PSCustomObject]@{ Protocol = $protocol Enabled = $protocolConfig.Enabled Server = if ([String]::IsNullOrEmpty($protocolConfig.Server)) { 'N/A' } else { $protocolConfig.Server } Port = if ($null -eq $protocolConfig.Port -or $protocolConfig.Port -lt 0) { 'N/A' } else { $protocolConfig.Port } } }) if ($enabledProxies.Count -gt 0) { $filteredRows = @($rows | Where-Object { $_.Enabled -eq $true }) $detail = "Outbound proxy configured for: $($enabledProxies -join '; '). Verify the proxy's health status before beginning the upgrade - see https://knowledge.broadcom.com/external/article/370265/how-to-configure-proxy-settings-for-vcen.html" return [PSCustomObject]@{ Status = 'Warning'; Detail = $detail; Rows = $filteredRows } } return [PSCustomObject]@{ Status = 'Pass'; Detail = 'No outbound proxy is configured for any protocol.'; Rows = $rows } } } |