Functions/Compare-MSPCompleteCustomer.ps1

<#
.SYNOPSIS
    This function performs a comparison between a reference customer object and a comparison customer object.
.DESCRIPTION
    This function performs a comparison between a reference customer object and a comparison customer object.
    It returns true if the objects match in both property values and extended property values,
    and false otherwise.
#>

function Compare-MSPCompleteCustomer {
    param (
        # The customer used as the reference object.
        [Parameter(Mandatory=$true)]
        $referenceCustomer,

        # The customer used as the comparison object.
        [Parameter(Mandatory=$true)]
        $comparisonCustomer
    )

    # Get list of properties to compare
    $propertiesToCompare = Get-MSPCompleteCustomerPropertyList

    # Compare properties
    foreach ($property in $propertiesToCompare) {
        # The property values are not the same
        if ("$($referenceCustomer.$property)" -ne "$($comparisonCustomer.$property)") {
            Write-Error "Property '$($property)' does not match for customer '$($referenceCustomer.CompanyName)' - Reference: '$($referenceCustomer.$property)' Comparison: '$($comparisonCustomer.$property)'"
            return $false
        }
    }

    # The two objects are the same
    return $true
}