Skip to content

Instantly share code, notes, and snippets.

@kasuken
Created October 29, 2020 04:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kasuken/18f11c829eb4673bd2d0f0c41ff11307 to your computer and use it in GitHub Desktop.
Save kasuken/18f11c829eb4673bd2d0f0c41ff11307 to your computer and use it in GitHub Desktop.
PowerShell script to remove all modern pages from SharePoint Online with PnP
$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