0

How to get all the pages inside a site? I will pass the parameter of a site in a site collection example: http://www.category.com/en,using powershell code in sharepoint server 2013.

when i try below command i can not get all sites under a site

Get-SPSite  https://xxxx/xx  -Limit All | Get-SPWeb -Limit All | Select -ExpandProperty AllWebs
4
  • Pages or subsites? Feb 22, 2016 at 12:41
  • hi i wants to get all pages in a site and its sub sites
    – adilahmed
    Feb 22, 2016 at 12:59
  • 2
    Pages as in the actual aspx pages in the library pages/site pages? The above is trying to get all the site collections in the farm and its subsites. Feb 22, 2016 at 13:27
  • yes ,i need subsites list in a site and pages
    – adilahmed
    Feb 22, 2016 at 13:45

1 Answer 1

2

This might be a starting point for you:

$site = Get-SPSite https://sharepoint.contoso.com

# This is enough to select all webs in site collection, you don't need to select AllWebs
$webs = Get-SPWeb -Site $site -Limit ALL

# Iterate all webs
foreach ($web in $webs) {
    # Get SitePages library. If you have multiple libraries or use publishing,
    # you need to execute it for all libraries.
    $sitePages = $web.Lists.EnsureSitePagesLibrary()
    # This will only get files from root folder. You can use $folder.SubFolders to get all files
    $sitePages.RootFolder.Files | Select ServerRelativeUrl
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.