####  report on the differences between the SharePoint list and the CMDB

function Compare-ITDVMSharePointToCmdb {
    [CmdletBinding()]
    param (
        
    )
    
    begin {
        
        $SPList = Get-ITDVMwareSharePointVMGuestList | Where-Object { $_.Status -ne "Delete" -and $_.Status -ne "Deleted" -and $_.Status -ne "Declined"}

        $ArrayList = [System.Collections.ArrayList]@()
        ForEach ($SPItem in $SPList) {
            Write-Verbose -message ($SPItem.Title) -Verbose
            $Cmdb = $null
            $Hostname = $null
            $obj = $null

            $Hostname = $SPItem.Title.split('.')[0]
            $Cmdb = Get-ITDServiceNowRecord -Table cmdb_ci_server -Filter "name=$HostName"

            $obj = [PSCustomObject]@{
                SPTitle               = $SPItem.Title;
                CmdbHostName          = $Cmdb.name.display_value;
                Environment           = $null;
                AppName               = $null;
                LicensingRestrictions = $null;
                DR_Protection         = $null;
                SRMRecoveryType       = $null;
            }

            If ($SPItem.Environment -eq $Cmdb.Environment.display_value) {
                $obj.Environment = $true
            }            Else {
                $obj.Environment = $false
            }

            If ($SPItem.AppName -eq $Cmdb.u_nd_application_svc.display_value) {
                $obj.AppName = $true
            }            Else {
                $obj.AppName = $false
            }

            If ($SPItem.LicensingRestrictions -eq $Cmdb.u_nd_licensing_restrictions.display_value) {
                $obj.LicensingRestrictions = $true
            }            Else {
                $obj.LicensingRestrictions = $false
            }

            switch ($SPItem.DR_Protection) {
                'None' {
                    If ($Cmdb.u_nd_dr_protection.display_value -eq 'No DR') {
                        $obj.DR_Protection = $true
                    }
                    Else {
                        $obj.DR_Protection = $false
                    }
                }
                'VMware: ABR' {
                    If ($Cmdb.u_nd_dr_protection.display_value -eq 'VMware: ABR') {
                        $obj.DR_Protection = $true
                    }
                    Else {
                        $obj.DR_Protection = $false
                    }
                }
                Default {
                    If ($Cmdb.u_nd_dr_protection.display_value -eq $SPItem.DR_Protection) {
                        $obj.DR_Protection = $true
                    }
                    Else {
                        $obj.DR_Protection = $false
                    }
                }
            }

            switch ($SPItem.SRM_RecoveryVMtype) {
                $null {
                    If ($null -eq $Cmdb.u_nd_srm_recovery_vm_type.display_value) {
                        $obj.SRMRecoveryType = $true
                    }
                    Else {
                        $obj.SRMRecoveryType = $false
                    }
                }
                'Reserved' {
                    If ($Cmdb.u_srm_recovery_type.display_value -eq 'Reserved') {
                        $obj.SRMRecoveryType = $true
                    }
                    Else {
                        $obj.SRMRecoveryType = $false
                    }
                }
                'Repurposed' {
                    If ($Cmdb.u_srm_recovery_type.display_value -eq 'Repurposed') {
                        $obj.SRMRecoveryType = $true
                    }
                    Else {
                        $obj.SRMRecoveryType = $false
                    }
                }
            }
    
            $ArrayList.Add($obj) | Out-Null
        }
    }
    
    process {
        
    }
    
    end {
        Write-Output $ArrayList
    }
}