Skip to content

Instantly share code, notes, and snippets.

@joerodgers
Created October 6, 2017 20:31
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joerodgers/14ad3ac2402bc753cd17a3fe8b9f70e5 to your computer and use it in GitHub Desktop.
Save joerodgers/14ad3ac2402bc753cd17a3fe8b9f70e5 to your computer and use it in GitHub Desktop.
Set the "NoCrawl" Attribute on the the RootWeb of an SPO Site Collection
# https://www.nuget.org/packages/Microsoft.SharePointOnline.CSOM
Add-Type -Path "C:\O365_CSOM\Microsoft.SharePointOnline.CSOM.16.1.6008.1200\lib\net45\Microsoft.SharePoint.Client.dll"
Add-Type -Path "C:\O365_CSOM\Microsoft.SharePointOnline.CSOM.16.1.6008.1200\lib\net45\Microsoft.SharePoint.Client.Runtime.dll"
$credential = Get-Credential -Message "SharePoint Online Site Administrator"
$context = New-Object Microsoft.SharePoint.Client.ClientContext( "https://contoso.sharepoint.com/sites/teamsite" )
$context.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($credential.UserName, $credential.Password)
$context.Load($context.Site.RootWeb.AllProperties)
$context.ExecuteQuery()
$context.Site.RootWeb.AllProperties["NoCrawl"] = "true" # true == hide from search
$context.Site.RootWeb.Update()
$context.ExecuteQuery()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment