# The directory to search
$searchpath = "C:\"
# List all rdl files from the given search path recusrivley searching sub folders, store results into a variable
$files = gci $searchpath -recurse -filter "*.rdl" | SELECT FullName, DirectoryName, Name
# for each of the found files pass the folder and file name and the xml content
$files | % {$Directory = $_.DirectoryName; $Name = $_.Name; [xml](gc $_.FullName)}
# in the xml content navigate to the the DataSets Element
| % {$_.Report.DataSets}
# for each query retrieve the Report directory , File Name, DataSource Name, Command Type, Command Text output thwese to a csv file
| % {$_.DataSet.Query} | SELECT @{N="Path";E={$Directory}}, @{N="File";E={$Name}}, DataSourceName, CommandType, CommandText | Export-Csv Test.csv -notype