Customers.psm1

<#
.SYNOPSIS
    This function returns a list of the properties present in an MSPComplete Customer object.
#>

function Get-MSPCompleteCustomerPropertyList {
    # Return the list of properties
    return @(
        "CompanyName",
        "PrimaryDomain",
        "CountryName",
        "StateProvinceName",
        "CityName",
        "CompanySizeBucket",
        "IndustryType"
    )
}

<#
.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.
.PARAMETER referenceCustomer
    The customer used as the reference object.
.PARAMETER comparisonCustomer
    The customer used as the comparison object.
#>

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
    )

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

        # Keep track of comparison result
        $result = $true

        # Compare properties
        foreach ($property in $propertiesToCompare) {
            if ($referenceCustomer.$property -ne $comparisonCustomer.$property) {
                Write-Error "Property '$($property)' does not match for customer '$($referenceCustomer.DisplayName)' - Reference: '$($referenceCustomer.$property)' Comparison: '$($comparisonCustomer.$property)'"
                return $false
            }
        }
    }
    catch {
        # Any exception means that comparison failed
        $result = $false
    }

    # Return the result of the comparison
    return $result
}