Public/Test-RdlcReference.ps1

function Test-RdlcReference
{
    param
    (
        [Parameter(Mandatory, ValueFromPipeline, ValueFromPipelineByPropertyName, Position = 0)]
        [Alias('FullName')]
        [string[]]$Path
    )

    process
    {
        $Path.ForEach{
            $CurrentPath = Resolve-Path -Path $_

            $DataSetFieldNames = Get-RdlcDatasetField -Path $CurrentPath | Select-Object -ExpandProperty Name
            $ReportParameterNames = Get-RdlcReportParameter -Path $CurrentPath | Select-Object -ExpandProperty Name
            $References = Get-RdlcReference -Path $CurrentPath
            $Result = $true

            $MissingDataSetFields = $References
            | Where-Object ReferenceType -EQ 'DataSetField'
            | Where-Object { $DataSetFieldNames -NotContains $_.Reference }

            $MissingReportParameters = $References
            | Where-Object ReferenceType -EQ 'ReportParameter'
            | Where-Object { $ReportParameterNames -NotContains $_.Reference }

            ($MissingDataSetFields, $MissingReportParameters)
            | ForEach-Object {
                Write-Error "$($_.ReferenceType) reference '$($_.Reference)' in lay-out file $($_.FileName) does not appear to point to a valid $($_.ReferenceType)"
                $Result = $false
            }

            $Result
        }
    }
}