Public/Get-RdlcReference.ps1

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

        [switch]$IncludeBlank,

        [switch]$IncludeLiteral
    )

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

            $Result = Select-Xml `
                -Path $CurrentPath `
                -XPath '//sql:ReportSections//sql:Value | //sql:ReportSections//sql:Format' `
                -Namespace @{'sql' = 'http://schemas.microsoft.com/sqlserver/reporting/2016/01/reportdefinition' }
            | ForEach-Object {
                $RawReference = $_.Node.InnerText
                $Reference = $RawReference -replace '^=', '' -replace '^Sum\((.*)\)$', '$1' -replace '^First\((.*)\)$', '$1' -replace ',"DataSet_Result"$', '' -replace '\.Value$', ''

                [ValidateSet('DataSetField', 'ReportParameter', 'Other')]$ReferenceType = switch -Regex ($Reference)
                {
                    '^Fields!'
                    {
                        $Reference = $Reference -replace '^Fields!', ''
                        'DataSetField'
                    }

                    '^Parameters!'
                    {
                        $Reference = $Reference -replace '^Parameters!', ''
                        'ReportParameter'
                    }

                    default
                    {
                        'Other'
                    }
                }

                [PSCustomObject]@{
                    PSTypeName    = 'UncommonSense.Rdlc.Utils.Reference'
                    Path          = $CurrentPath
                    FileName      = Split-Path -Path $_.Path -Leaf
                    Type          = $_.Node.Name
                    RawReference  = $RawReference
                    ReferenceType = $ReferenceType
                    Reference     = $Reference
                }
            }

            $Result = if (-not $IncludeBlank) { $Result | Where-Object { $_.RawReference } } else { $Result }
            $Result = if (-not $IncludeLiteral) { $Result | Where-Object { $_.RawReference -like '=*' } } else { $Result }

            $Result
        }
    }
}