How to get a list of all pages in the SitePages Library and their type using PowerShell?

I have created the pages, some are wiki pages and webpart pages.


Use the following Script:

$spWeb = Get-SPWeb SiteUrl
$listName = "Site Pages"
 $list = $spWeb.Lists |? {$_.Title -eq $listName}
  foreach ($item in $list.Items) 
  Write-Host $item["ContentType"]
| improve this answer | |

The following script prints pages information from Site Pages library:

Get-SPWeb http://contoso.intranet.com/ |
Select -ExpandProperty Lists |
Where { $_.Title -eq "Site Pages" } |
Select -ExpandProperty Items |
Select Name, url, {$_["ContentType"]} 
| improve this answer | |
  • I am checking this in PnP powershell i am not getting the ContentType name for each list item – Liz Jul 2 at 11:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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