jeudi 19 mars 2015

How to get URL of all site pages in SharePoint 2010 with PowerShell



I'm building a PowerShell script to get the url's for my SharePoint sites' pages (see below)



$siteURL = "http://mysite"
$site = new-object microsoft.sharepoint.spsite($siteURL)
$webApp = $site.webapplication
$allSites = $webApp.sites
$customLinkObjects =@()
foreach ($site in $allSites) {
$allWebs = $site.AllWebs
foreach ($web in $allWebs) {
$lists = $web.Lists
#Looking for lists of type Site Pages
if($list.Title -eq "Site Pages") {
# Going through all the pages in a Site Pages List
foreach ($item in $list.Items) {
$pageURL = XXXXXXXX
}
}
}


I'm struggling a bit in the last nested foreach and I wonder:



  • Is $list.Title -eq "Site Pages" the best way to identify a list of that "type"?

  • Once I'm iterating the Site Pages list items, how can I set the &pageURL variable?








0 commentaires:

Enregistrer un commentaire