I am using SharePoint 2013 On Premises. I am trying modify the values Exclude from Internet Search Engines( Present in Edit SEO Properties of a page, RobotsNoIndex field) with respect to Include/Exclude internal Search ( Present in Edit Properties, TSExternalSearch field), such that when Internal Search is marked as "Hide", "Exclude from sitemap and hide from Search Engines" is selected for Internet Search Engines. I am trying to achieve this feat for a single page in document library as of now.
Here is the partial code:
Add-Type -Path 'C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.dll'
Add-Type -Path 'C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.Runtime.dll'
Add-Type -Path 'C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.Publishing.dll'
Add-Type -Path 'C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.Taxonomy.dll'
$siteURL = "http://dvsandboxv2-07:46000/"
$spSite = [Microsoft.SharePoint.SPSite] ($siteURL)
if($spSite -ne $null)
{
"Site Collection : " + $spSite.Url
foreach($subWeb in $spSite.AllWebs)
{
if($subWeb -ne $null)
{
$spListColl = $subweb.Lists
foreach($eachList in $spListColl)
{
if($eachList.Title -eq "Pages")
{
$PagesUrl = $subweb.Url + "/"
foreach($eachPage in $eachList.Items)
{
$eachPage.CheckOut()
if($eachPage['TSExternalSearch'] -eq "Hide")
{
$eachPage['RobotsNoIndex'] = 0
$eachPage.Update()
}
else
{
$eachPage['RobotsNoIndex'] = 1
$eachPage.Update()
}
$eachPage.File.CheckIn("check in comment", [Microsoft.SharePoint.Client.CheckinType]::MajorCheckIn)
$eachPage.File.Publish(" ")
}
}
}
$subWeb.Dispose()
}
else
{
Echo $subWeb "does not exist"
}
}
$spSite.Dispose()
}
else
{
Echo $siteURL "does not exist, check the site collection url"
}
Echo Finish
Can you help me with some hints or directions on how should I move ahead with this problem. Any help would be appreciated!
Thanks