SOLVED

How to publish all pages in SitePages library?

Copper Contributor

I have 4 500 modern pages in my pages library and all are minor versions. I need to publish all. Does anyone have a PowerShell script for this?

4 Replies
best response confirmed by Papageno Sweden (Copper Contributor)
Solution

PnP PowerShell is the way I always find easiest for this:

 

Connect-PnPOnline -Url "<your site url here>"

$pageslib = Get-PnPList -Identity "Site Pages"

$pages = Get-PnPListItem -List $pageslib

foreach($page in $pages){
$page.File.Publish("Published")
}

Invoke-PnPQuery

Exactly what I was looking for. Thanks for your quick reply.

@Matt Weston 

Hi, what should I add on this script to allow the same result for list with more than 5000 items? I am getting list view threshold error. I am on SharePoint Online. 

Ryan_Linsangan_0-1606210743971.png

 

 

Its not publishing pages as in my Site Pages library I have few pages published and most of them unpublished
1 best response

Accepted Solutions
best response confirmed by Papageno Sweden (Copper Contributor)
Solution

PnP PowerShell is the way I always find easiest for this:

 

Connect-PnPOnline -Url "<your site url here>"

$pageslib = Get-PnPList -Identity "Site Pages"

$pages = Get-PnPListItem -List $pageslib

foreach($page in $pages){
$page.File.Publish("Published")
}

Invoke-PnPQuery

View solution in original post