Created
October 6, 2017 20:31
-
-
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
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
# 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