当前位置:网站首页 > 更多 > 玩电脑 > 正文

[玩转系统] 使用 PowerShell 限制 SharePoint 内容数据库中网站集的最大数量

作者:精品下载站 日期:2024-12-14 20:58:12 浏览:14 分类:玩电脑

使用 PowerShell 限制 SharePoint 内容数据库中网站集的最大数量


默认情况下,SharePoint 2013 内容数据库中的最大网站集数设置为 5000,警告级别为 2000 作为初始配置。尽管从技术上讲,SharePoint 2013 内容数据库最多可容纳 10,000 个网站集(2,500 个非个人网站集和 7,500 个个人网站,或仅 10,000 个个人网站),但建议限制为 5000 个!

有时您可能希望将数据库专用于单个网站集。当您从中央管理创建网站集时,该网站会自动放置在任何可用的内容数据库中。为了防止在特定内容数据库上创建任何其他站点,我们可以设置最大站点数限制!要设置特定内容数据库中网站集的最大数量,请导航至:

  • SharePoint 2013 管理中心 >> 应用程序管理 >> 管理内容数据库
  • 选择附加特定内容数据库的目标 Web 应用程序
  • 从列表中选择目标数据库
  • 现在,在“管理内容数据库设置”页面上,您可以设置内容数据库的最大站点数。

[玩转系统] 使用 PowerShell 限制 SharePoint 内容数据库中网站集的最大数量

确保您的最大站点数大于或等于当前站点数。

用于设置网站集最大数量限制的 PowerShell 脚本:

应为附加到特定 Web 应用程序的每个内容数据库配置此设置。当您有许多内容数据库时,您可以使用以下 PowerShell 脚本来设置单次扩展中的最大站点数。


Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

#Variables for processing
$WebAppURL ="https://Intranet.Crescent.com"
$MaxSiteCount=1
$WarningSiteCount = 0

#Get all content databases of the web application
$ContentDBColl = Get-SPContentDatabase -webapplication $WebAppURL

#Iterate through each database in the web application
foreach($Database in $ContentDBColl) 
{
    #Check the current No. of sites 
    if($MaxSiteCount -ge $Database.CurrentSiteCount)
    {
        #Set Maximum Sites, warning level Counts
        Set-SPContentDatabase -Identity $Database.Name -MaxSiteCount $MaxSiteCount -WarningSiteCount $WarningSiteCount
        Write-host "Max Sites Settings updated for the database:" $Database.name -ForegroundColor Green
    }
    else
    {
        write-host "MaxSiteCount must be > = current site count! No changes made in $($Database.Name)" -ForegroundColor Red
    }
}

锁定所有现有内容数据库以限制网站集数量

让我们锁定所有现有的内容数据库并防止在其上创建新的网站集。


Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

#Variables for processing
$WebAppURL ="https://Intranet.Crescent.com"

#Get all content databases of the web application
$ContentDBColl = Get-SPContentDatabase -webapplication $WebAppURL

#Iterate through each database in the web application
foreach($Database in $ContentDBColl) 
{
    #Get the current Number of sites 
    $Count = $Database.Sites.Count
    if($Count -gt 0)
    {
        $WarniningCount = $Count - 1
        #Set Maximum Sites, warning level Counts
        Set-SPContentDatabase $Database.Name -MaxSiteCount $Count -WarningSiteCount $WarniningCount

        Write-host "Current Number of Sites in $($Database.Name) is $($Database.Sites.Count)"
    }
}

您需要 登录账户 后才能发表评论

取消回复欢迎 发表评论:

关灯