SharePoint: Using GUID in SharePoint and Powershell

The following example shows how to use GUIDs in Powershell. Notice the use of GUID]($webIdWe don't need to use new-object to create GUID.

$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

+