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

[玩转系统] SharePoint Online:使用 PowerShell 更改网站集的存储配额

作者:精品下载站 日期:2024-12-14 21:06:36 浏览:16 分类:玩电脑

SharePoint Online:使用 PowerShell 更改网站集的存储配额


要求:使用 PowerShell 增加 SharePoint Online 中的存储配额。

如何在 SharePoint Online 中设置网站集的存储配额?

默认情况下,SharePoint Online 使用分配给租户的存储池中的自动存储配额管理来减少管理员的工作量。但是,您可以接管存储管理并调整每个集合的站点配额。要设置 SharePoint 网站集的存储配额,请执行以下步骤:

  1. 登录到 SharePoint Online 管理中心 (https://-admin.sharepoint.com)。
  2. 展开“站点”>> 单击左侧导航中的“活动站点”。
  3. 选择网站集以设置其存储限制。单击工具栏上的“存储”按钮。 (仅当存储管理选项设置为“手动”时,您才会在工具栏中看到“存储”选项!有关在 SharePoint Online 中设置存储管理选项的更多信息,请参阅:Office 365:管理 SharePoint Online 中的网站存储限制)
  4. 这将打开“编辑存储限制”面板来设置所选网站集的存储限制。输入最大存储值(以 GB 为单位)。假设,您想要为网站集分配 10 TB 的存储空间。输入“10240”。您还可以设置警告阈值,以便网站所有者在达到阈值时收到通知。

    [玩转系统] SharePoint Online:使用 PowerShell 更改网站集的存储配额

增加经典管理中心中的站点存储配额:

如果您使用经典管理中心,请单击左侧导航中的“网站集”链接。从可用网站集中选择目标网站集以更改存储配额,然后单击功能区中的“存储配额”按钮。

[玩转系统] SharePoint Online:使用 PowerShell 更改网站集的存储配额

从存储配额页面输入网站集的新配额。当存储达到特定阈值时,您可以选择启用向站点管理员发送电子邮件通知。

[玩转系统] SharePoint Online:使用 PowerShell 更改网站集的存储配额

单击“保存”将新的存储配额应用到您的 SharePoint Online 网站。

如何在 SharePoint Online 中使用 PowerShell 更改存储配额

若要在 SharePoint Online 中设置存储配额,请使用 Set-SPOSite cmdlet。以下是如何使用 PowerShell 增加 SharePoint Online 中的存储配额:

步骤 1: 以 SharePoint Online 管理员或租户管理员身份连接到 SharePoint Online


$AdminURL="https://crescent-admin.sharepoint.com"
Connect-SPOService -URL $AdminURL -Credentials (Get-Credential) 

步骤 2: 使用 Set-SPOSite cmdlet 更改存储配额。


$SiteURL="https://crescent.sharepoint.com/sites/marketing"
#Set Storage Quota
Set-SPOSite -Identity $SiteURL -StorageQuota 2048

执行需要一段时间,并将给定网站集的存储配额设置为 2GB。您可以从管理站点验证新的存储配额。

[玩转系统] SharePoint Online:使用 PowerShell 更改网站集的存储配额

使用 PnP PowerShell 设置站点的存储配额:

让我们使用 PnP PowerShell 将网站集的存储限制设置为 10 GB。


#Set Parameters
$TenantAdminURL = "https://Crescent-admin.sharepoint.com"
$SiteURL = "https://Crescent.sharepoint.com/sites/Sales"

#Connect to SharePoint Admin Center
Connect-PnPOnline -Url $TenantAdminURL -Interactive

#set storage quota for the site in MBs
Set-PnPTenantSite -Url $SiteURL -StorageWarningLevel 8192 -StorageMaximumLevel 10240

如何增加所有网站集的存储配额?
以下是在 SharePoint Online 中设置配额的 PowerShell:


#Get all the site collection
$AllSites = Get-SPOSite -Limit All

#Set Storage quota for each site collection
Foreach ($Site in $AllSites)
{
   #set quota on sharepoint online site powershell
   Set-SPOSite -Identity $Site.URL -StorageQuota 10000 -StorageQuotaWarningLevel 8000
}

该脚本盲目地将所有网站集的存储配额设置为 10 GB。如果您的存储空间不足,您可以为订阅购买额外的存储空间。

增加 SharePoint Online 中的存储空间

将现有配额增加特定存储空间怎么样?例如,向现有网站添加 5 GB?


Import-Module Microsoft.Online.SharePoint.Powershell -DisableNameChecking

#Parameters
$AdminCenterURL="https://Crescent-Admin.SharePoint.com"
$SiteURL = "https://Crescent.SharePoint.com/sites/marketing"
$QuotaIncrease = 5 #5 GB

#Setup Credentials to connect
$Cred = Get-Credential

Connect-SPOService -Url $AdminCenterURL -Credential $Cred
      
#Get the Site Collection
$Site = Get-SPOSite -Identity $SiteURL -Detailed

#Calculate New Storage Quota
$CurrentStorage = $Site.StorageQuota
$NewStorage = $CurrentStorage + ($QuotaIncrease * 1024)

#increase storage quota in sharepoint online
Set-SPOSite -Identity $SiteURL -StorageQuota $NewStorage
Write-Host "Storage Quota set from '$CurrentStorage' to '$NewStorage'" -f Green

请注意,这些配额更改仅在租户存储方式为手动时才会生效!这是有关在 SharePoint Online 中生成存储配额报告的另一篇文章:SharePoint Online:使用 PowerShell 获取站点存储配额报告

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

取消回复欢迎 发表评论:

关灯