Private/Checks/VCenter/Test-VcfVcenterDetectLegacyPlugin.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-VcfVcenterDetectLegacyPlugin {

    <#
        .SYNOPSIS
        Detects legacy vCenter plugins (Site Recovery Manager, Dell EMC RecoveryPoint) requiring remediation prior to a VCF upgrade.

        .DESCRIPTION
        Queries vCenter extension registration across all vCenters connected to SDDC Manager via
        Get-VcfCheckVCenterExtension.

        Evaluates registered extensions for legacy plugins:
        - Site Recovery Manager (SRM): Matched by extension Key or Description.Label containing "srm"
          or "Site Recovery Manager".
        - Dell EMC RecoveryPoint: Matched by exact extension key 'com.emc.recoverpoint.vwc'.

        Evaluation logic:
        - Warning: One or more legacy plugins are registered, indicating software requiring removal
          or transition before upgrade.
        - Skipped: Neither SRM nor Dell EMC RecoveryPoint plugins are registered.

        Delegates per-vCenter execution and result aggregation 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_detect_legacy_plugin' -Area vCenter -DisplayName $DisplayName -Body {
        param($Context, $VCenterFqdn)
        $extensions = Get-VcfCheckVCenterExtension -Server $VCenterFqdn

        $srmExtension = $extensions | Where-Object {
            $_.Key -match 'srm' -or $_.Description.Label -match 'Site Recovery Manager'
        } | Select-Object -First 1
        $rpExtension = $extensions | Where-Object { $_.Key -eq 'com.emc.recoverpoint.vwc' } | Select-Object -First 1

        if (-not $srmExtension -and -not $rpExtension) {
            return [PSCustomObject]@{ Status = 'Skipped'; Detail = 'No legacy plugins (SRM, Dell EMC RecoveryPoint) are registered as vCenter extensions.'; SkipReasonTag = 'No relevant legacy plugins registered'; Rows = @() }
        }

        $rows = @()
        $details = @()

        if ($srmExtension) {
            $rows += [PSCustomObject]@{
                Plugin = 'Site Recovery Manager (SRM)'
                Key = $srmExtension.Key
                Description = $srmExtension.Description.Label
                Version = $srmExtension.Version
            }
            $details += "Site Recovery Manager detected (extension key `"$($srmExtension.Key)`", version $($srmExtension.Version)) - SRM is EOL, see https://techdocs.broadcom.com/us/en/vmware-cis/live-recovery/live-recovery-appliance/9-0-5/next-release-is-part-of-protection-and-recovery.html and plan to transition as part of the VCF 9 upgrade."
        }

        if ($rpExtension) {
            $rows += [PSCustomObject]@{
                Plugin = 'Dell EMC RecoveryPoint'
                Key = $rpExtension.Key
                Description = $rpExtension.Description.Label
                Version = $rpExtension.Version
            }
            $details += "Dell EMC RecoveryPoint detected (extension version $($rpExtension.Version)) - RecoveryPoint for Virtual Machines is EOL, see https://www.dell.com/support/product-details/en-us/product/recoverpoint-for-virtual-machines/overview and remove it before upgrading to VCF 9."
        }

        return [PSCustomObject]@{ Status = 'Warning'; Detail = ($details -join ' '); Rows = $rows }
    }
}