Last active
July 31, 2020 10:27
-
-
Save pkbullock/6637aa65e875829102e0ab95179d3a4a to your computer and use it in GitHub Desktop.
Set 404 Property on SharePoint site
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
$tenant = "<tenant>" | |
$site = "<site>" | |
$siteUrl = "https://$($tenant).sharepoint.com/sites/$($site)" | |
Write-Host "Setting 404 page at $($siteUrl)..." | |
# Connect to SharePoint Online with PnP PowerShell library | |
Connect-PnPOnline $siteUrl -UseWebLogin | |
# Disable NoScript | |
Write-Host " Disabling NoScript" -ForegroundColor Cyan | |
Set-PnPTenantSite -Url $siteUrl -NoScriptSite:$false | |
# Sets the value in the property bag, note: ensure you have disabled NoScript | |
Write-Host " Adding Property Bag Key" -ForegroundColor Cyan | |
Set-PnPPropertyBagValue -Key "vti_filenotfoundpage" -Value "/sites/$($site)/SitePages/Page-not-found.aspx" | |
# Enable NoScript | |
Write-Host " Enabling NoScript" -ForegroundColor Cyan | |
Set-PnPTenantSite -Url $siteUrl -NoScriptSite | |
Write-Host "Script Complete! :)" -ForegroundColor Green |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment