Created
October 29, 2020 04:58
-
-
Save kasuken/18f11c829eb4673bd2d0f0c41ff11307 to your computer and use it in GitHub Desktop.
PowerShell script to remove all modern pages from SharePoint Online with PnP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$siteUrl = "" | |
Connect-PnPOnline –Url $siteUrl -UseWebLogin | |
$items =Get-PnPListItem -List "SitePages" -PageSize 1000 | |
foreach ($item in $items) | |
{ | |
if ($item.Id -ne 1) | |
{ | |
try | |
{ | |
Write-Host $item.Id | |
Remove-PnPListItem -List "SitePages" -Identity $item.Id -Force | |
} | |
catch | |
{ | |
Write-Host “error” | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment