问题
我们有一个外联网,可以将组隔离到单独的网站集中。为了防止通过搜索泄露信息,我们将所有站点的搜索可见性设置为“从不索引 ASPX 页面”。由于站点管理员可以更改该设置,因此我们计划使用一个脚本来报告任何已启用 ASPX 索引的站点并安排它定期运行。以下是我到目前为止所拥有的。它仅报告每个网站集的根网站。我将为网站集中的所有网站添加一个循环,但可以等到脚本运行。
当我更改开发框中某个根站点的搜索设置时,“http://spdevlc01”我看不到脚本输出有任何变化。AllowAutomaticASPXPageIndexing的MSDN 页面表明它确实在检测站点上细粒度权限的使用,而不是实际配置设置本身,因此我添加了检索 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