SharePoint: SPSiteDataQuery and Powershell

Scenario: Consider a scenario where we need to show the url of all pages present in the Pages libraries present in a site collection. The main thing to notice here is that the ServerTemplate of Pages Library is 850. Following PowerShell code can be used to accomplish it:

$siteCollectionUrl = "http://sp2010"
$site =new-object Microsoft.SharePoint.SPSite($siteCollectionUrl)
$query = new-object Microsoft.SharePoint.SPSiteDataQuery
$query.Webs = "<Webs Scope='SiteCollection'>"
$query.Lists = "<Lists ServerTemplate='850' />"
$results = $site.rootweb.GetSiteData($query)
foreach($row in $results.rows)
{
  $listId = $row["ListId"]
  $webId = $row["WebId"]
  $childWeb = $site.OpenWeb([GUID]($webId))
  $pagesList = $childWeb.Lists[[GUID]($listId)];
  $itemUrl = $childWeb.Url + "/" + $pagesList.RootFolder.Url
  Write-Host $itemUrl 
  $childWeb.Dispose()
}
$site.Dispose()
profile for Nadeem Yousuf at SharePoint Stack Exchange, Q&A for SharePoint enthusiasts

+