Activate Global Search for Modern Site

The Modern SharePoint by default only allows you to search inside that specific site. However, the new version of SharePoint PNP PowerShell allows you to activate the Search for all SharePoint instead of just that specific site.

Update the PNP PowerShell for the latest version.

Update-Module SharePointPnPPowerShell*
Connect-PnPOnline -Url "https://contoso.sharepoint.com/sites/SITENAME/" -UseWebLogin
 
try{
 $web = Get-PnPWeb
 #1 to activate Global Search and 0 to deactivate Global Search
 $web.SearchScope = 0 
 $web.Update()
 Invoke-PnPQuery
 Write-Host "Done" -BackgroundColor Green	
}
catch{
 Write-Host "No permission" -BackgroundColor Red	
}
Write-Host "All Done"
Write-Host "Press any key to Close..."
$Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")

Conclusion

The Modern Site where you run this script will now search on all SharePoint Sites. To make the search to go on original behavior on SearchScope switch the value for 0.

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *