使用PowerShell检测SharePoint 2010网站的搜索设置

时间:2012-05-09 15:00:25

标签: sharepoint search powershell

问题

我们有一个外联网将组隔离到单独的网站集中。为了防止信息通过搜索泄漏,我们将所有网站搜索可见性设置为“从不索引ASPX页面”。由于站点管理员可以更改该设置,因此我们计划使用一个脚本来报告已启用ASPX索引并安排定期运行的任何站点。以下是我到目前为止的情况。它仅报告每个网站集的根网站。我将为网站集中的所有网站添加一个循环,但是可以等到脚本正常工作。

当我在开发框中更改其中一个根网站的搜索设置时,“http:// spdevlc01”我看不到对脚本输出的任何更改。 MSDN page for AllowAutomaticASPXPageIndexing表示它确实检测到在网站上使用细粒度权限,而不是实际上是配置设置本身,所以我添加了行来检索WebASPXPageIndexMode。当我手动将设置更改为“从不索引此站点上的任何Web部件”并运行脚本时,为该站点返回的WebASPXPageIndexMode值不会更改,它始终显示“0”,这意味着自动建立索引。

脚本

# Down to Set-Location $home, copied form SharePoint Management Shell. Need to be in place to have the SharePoint cmdlets and prevent memory leak.
$ver = $host | select version
if ($ver.Version.Major -gt 1)  {$Host.Runspace.ThreadOptions = "ReuseThread"}
Add-PsSnapin Microsoft.SharePoint.PowerShell
Set-location $home

# Get all the web applications in the farm, minus Central Admin
$webApplications = Get-SPWebApplication

# Enumerate all SharePoint web application
foreach($webApplication in $webApplications.GetEnumerator())
{
    # Enumerate all the site collections in the web application.
    foreach($siteCollection in $webApplication.sites)
    {
       # Reference to the AllowAutomaticASPXIndexing: http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spweb.allowautomaticaspxpageindexing.aspx
       $rootWeb = $siteCollection.RootWeb
       "$($rootWeb.Url) : $($rootWeb.AllowAutomaticASPXPageIndexing)"  
       "$($rootWeb.Url) : $($rootWeb.WebASPXPageIndexMode -as [int]) " 

       $rootWeb.Close()
       $siteCollection.Close()
    }
}

输出

http://spdevlc01:22000/sites/GetTogether : False
http://spdevlc01:22000/sites/GetTogether : 0
http://spdevlc01:22000/sites/KB : False
http://spdevlc01:22000/sites/KB : 0
http://spdevlc01:22000/sites/TW :
http://spdevlc01:22000/sites/TW : 0
http://spdevlc01 : False
http://spdevlc01 : 0

0 个答案:

没有答案