临时禁用大型列表上的列表视图阈值

临时禁用大型列表上的列表视图阈值

临时禁用大型列表上的列表视图阈值

正文:

在 SharePoint 2010 中,添加了一些新限制以保护服务器并避免用户执行其他用户无意中执行的代价很高的操作。有关 SharePoint 2010 软件边界和限制的完整列表,请单击此处 http://technet.microsoft.com/zh-cn/sharepoint/ff601870.aspx。如果您希望了解更多有关不同限制的含义的信息,请单击此处来阅读帮助主题 http://office2010.microsoft.com/zh-cn/sharepoint-server-help/HA010378155.aspx。若要更深入地了解可帮助管理大型列表的功能和涉及的最佳实践,请阅读此白皮书:设计大型列表并最大化列表性能(该链接可能指向英文页面) http://technet.microsoft.com/zh-cn/library/ff608068.aspx(该链接可能指向英文页面)

列表视图阈值是属于每个 Web 应用程序的“资源限制”设置的阈值之一,可在管理中心管理它。默认情况下,它设置为 5,000;这意味着任何试图一次处理 5,000 项以上的视图或查询都将被 SharePoint Server 阻止。例如,根据具有 5,001 项的列表中的未索引列进行筛选的视图将收到一条消息,通知用户查询被列表视图阈值阻止,并且如果设置了每日时间段,则该消息还将说明允许此操作的时间段。

升级后不久,一些用户可能发现他们无法通过现有视图访问数据;若要以他们所需的方式访问数据(例如,按名为“color”的列排序),他们必须为大型列表添加索引。不过,他们仍达到列表视图阈值限制,因此无法执行此任务,除非:

1.他们等到管理员设置的每日时间段(如果设置并启用了它)。默认情况下,未设置每日时间段,因为它需要是管理员一方推断哪些时间最适合作为组织的“非高峰期”的有意识的决策。这是建议的操作过程,但有时如果用户需要立即能够访问该数据,则这还不够。

2.服务器场管理员将列表视图阈值提高到非常高的数字,以便具有大型列表的每个人都可以访问其所有视图。这是强烈反对的,因为它为服务器的健康和稳定性带来很高风险,并且它不是解决少数人所拥有的问题,而是潜在为其他所有人带来问题,并建议使用结构不好的视图和查询。

3.管理员为用户的特定列表授予列表视图阈值的临时豁免。此豁免只能以编程方式执行。我将在此处演示如何可以实现此目的,以及如何在您为用户指定的期限到期后取消豁免。我强烈建议您非常谨慎地授予此例外,并只保留所需时间长度。在大多数情况下,给用户一周时间修复其视图或自定义代码就足够了。

若要为特定列表禁用列表视图阈值,您可以使用对象模型来将列表的“EnableThrottling”属性编辑为 false(默认为 true)。下面的代码演示如何为一个特定列表或某个网站下的所有列表执行此操作。最好只将此豁免授予特定列表,而非整个网站,因为精细地提供它可以更加轻松地跟踪可能导致服务器执行状况不好的内容,以及加强尽快修复列表对最终用户的重要性。

   1: 下面是 SharePoint 工作组的测试人员 Chris Clark 编写的用于执行此更改的脚本。若要取消此更改(即移除 Web 中的一个列表或所有列表上的例外),只需将下行
   2:  
   3: $list.EnableThrottling = $false
   4:  
   5: 更改为: 
   6:  
   7: $list.EnableThrottling = $true
   8:  
   9: ###########################################################################
  10:  
  11: # MakeExceptionLIst Script
  12:  
  13: # OnFailure: NONE
  14:  
  15: # OnSuccess: Changes SPList settings to make one or more lists under an SPWeb Exception Lists 
  16:  
  17: # 
  18:  
  19: # Input Parameters:
  20:  
  21: # - WebUrl ~ The URL of the SPWeb which contains the lists to be made exception lists
  22:  
  23: # - ListName (Optional) ~ The name of the list to make an exception list
  24:  
  25: # 
  26:  
  27: # Ex:
  28:  
  29: # makeexceptionlist.ps1 -WebUrl http://localhost -ListName "Shared Documents"
  30:  
  31: # makeexceptionlist.ps1 -WebUrl http://localhost/sites/site1 -ListName "*"
  32:  
  33: #
  34:  
  35: # Exit code rule:
  36:  
  37: # On success, exit 0
  38:  
  39: # On failure, if no other scripts depend on this, exit a none-zero value
  40:  
  41: # 
  42:  
  43: # Do not use "return" to give the caller exit code, as this cannot be 
  44:  
  45: # captured by the caller process.
  46:  
  47: ###########################################################################
  48:  
  49: Param([string]$WebUrl = "", [string]$ListName = "")
  50:  
  51: # Add Sharepoint pssnapin
  52:  
  53: Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue 
  54:  
  55: ###########################################################################
  56:  
  57: #
  58:  
  59: # Turn off/on list throttling on selected list
  60:  
  61: #
  62:  
  63: ###########################################################################
  64:  
  65: Function UpdateList($list)
  66:  
  67: {
  68:  
  69: $listname = $list.Title
  70:  
  71: Write-Host "Making list $listname an exception list"
  72:  
  73: $list.EnableThrottling = $false
  74:  
  75: $list.Update()
  76:  
  77: }
  78:  
  79: ###########################################################################
  80:  
  81: #
  82:  
  83: # Retrieve relevant objects (SPWeb, SPList) for operation and call Update
  84:  
  85: #
  86:  
  87: ###########################################################################
  88:  
  89: $web = Get-SPWeb $WebUrl
  90:  
  91: if( $web -eq $NULL )
  92:  
  93: {
  94:  
  95: Write-Host "Web not found. Exiting"
  96:  
  97: exit 1;
  98:  
  99: }
 100:  
 101: if ( $ListName -eq "*" )
 102:  
 103: {
 104:  
 105: Write-Host "Locating all Lists under web..."
 106:  
 107: $lists = $web.Lists
 108:  
 109: foreach( $list in $lists )
 110:  
 111: {
 112:  
 113: UpdateList( $list ) 
 114:  
 115: }
 116:  
 117: }
 118:  
 119: elseif ( $ListName -ne "" )
 120:  
 121: {
 122:  
 123: Write-Host "Locating List < $ListName >..."
 124:  
 125: $list = $web.Lists[$ListName] 
 126:  
 127: if ( $list -ne $NULL )
 128:  
 129: {
 130:  
 131: Write-Host "List found!"
 132:  
 133: UpdateList( $list )
 134:  
 135: }
 136:  
 137: else
 138:  
 139: {
 140:  
 141: Write-Host "List not found. Exiting"
 142:  
 143: exit 1;
 144:  
 145: }
 146:  
 147: }
 148:  
 149: else
 150:  
 151: {
 152:  
 153: Write-Host "Invalid List Name"
 154:  
 155: exit 1;
 156:  
 157: }
 158:  
 159: Write-Host "Done!"
 160:  
 161: exit 0;
 162:  
 163: ###########################################################################
 164:  
 165: # 
 166:  
 167: # End
 168:  
 169: #
 170:  
 171: ###########################################################################
posted @ 2012-02-24 12:07  love007  阅读(364)  评论(0编辑  收藏  举报