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

[玩转系统] SharePoint Online:使用 PowerShell 获取网站集存储大小 - 配额使用情况报告

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

SharePoint Online:使用 PowerShell 获取网站集存储大小 - 配额使用情况报告


要求:生成报告以分析所有 SharePoint Online 网站集存储消耗。

您是否正在寻找一种方法来查找 SharePoint Online 中网站集的存储使用情况?在这篇博文中,我们将向您展示如何收集网站集的存储详细信息并生成一个报告,以显示 SharePoint Online 租户中所有网站集的存储消耗情况。

本文将向您展示三种查找 SharePoint Online 网站大小的方法:

  1. 从 SharePoint Online 管理中心查找网站集大小
  2. 从网站的“存储指标”页面获取网站集的大小
  3. 使用 PowerShell 获取 SharePoint Online 网站的大小

如何获取 SharePoint Online 网站集的存储指标?

如何在 SharePoint Online 中检查网站集大小?要通过 Web 浏览器界面查找网站集的存储详细信息,请转至:

  1. 浏览到您的网站集 >> 单击“设置”齿轮 >> 网站信息 >> 然后选择“查看所有网站设置”。
  2. 在“网站设置”页面的“网站集管理”下,单击存储指标。

    [玩转系统] SharePoint Online:使用 PowerShell 获取网站集存储大小 - 配额使用情况报告

此页面提供 SharePoint 网站集存储详细信息以及所有子网站、文档库、文件夹、文件及其大小的细分。当尝试确定您的网站集是否使用了过多的存储空间并需要清理时,此信息会很有帮助。附带说明一下,回收站文件也计入您的存储配额。清空回收站将释放该空间。

您还可以使用 SharePoint Designer 查找网站使用的总存储空间。使用 SharePoint Designer 打开网站集,在主页的“网站信息”部分下,您将找到“已使用的总存储空间”!

获取 SharePoint Online 管理中心中所有网站的存储使用情况:

同样,要检查 SharePoint Online 中所有网站集的存储使用情况,

  1. 登录 SharePoint Online 管理中心:https://-admin.sharepoint.com
  2. 展开站点 >> 活动站点。此页面为您提供租户中所有站点的列表,以及每个站点的存储消耗和整个租户的总存储使用量。您也可以通过单击“导出”链接将此数据导出为 CSV。

    [玩转系统] SharePoint Online:使用 PowerShell 获取网站集存储大小 - 配额使用情况报告

SharePoint Online 包含多少存储空间?
分配给您的 SharePoint Online 租户的总存储空间取决于您的订阅计划和许可证数量。您拥有 1 TB 的总存储空间以及您购买的任何计划的 10 GB 每用户许可证。您可以为 Microsoft 365 购买额外的文件存储插件。

SharePoint Online:使用 PowerShell 获取网站集大小

让我们使用 PowerShell 脚本来获取分配的存储大小、已使用的存储空间和警告级别指标。若要获取 SharePoint Online 网站集的大小,可以使用 PowerShell 中的 Get-SPOSite cmdlet。此 cmdlet 检索网站大小以及有关网站集的其他信息,例如 URL、所有者、存储配额等。此脚本使用 PowerShell 获取单个网站集的存储信息:


#Config Parameters
$AdminSiteURL="https://crescent-admin.sharepoint.com"
$SiteURL="https://crescent.sharepoint.com/sites/Ops"

#Get Credentials to connect to SharePoint Admin Center
$Cred = Get-Credential

#Connect to SharePoint Online Admin Center
Connect-SPOService -Url $AdminSiteURL -Credential $Cred

#Get the Site collection
$Site = Get-SPOSite $SiteURL

#powershell to get sharepoint online site size
Write-Host "Allocated:"$Site.StorageQuota
Write-Host "Used:"$Site.StorageUsageCurrent
Write-Host "Warning Level:"$Site.StorageQuotaWarningLevel

此 PowerShell 检索 SharePoint Online 网站集配额(以 MB 为单位)。

SharePoint Online:使用 PowerShell 生成网站集大小报告

如何使用 PowerShell 获取 SharePoint Online 中的存储配额?此 PowerShell 脚本获取存储详细信息,例如 SharePoint Online 中所有网站集的分配总大小和消耗。


#Config Parameters
$AdminSiteURL="https://crescent-admin.sharepoint.com"
$ReportOutput="C:\Temp\SPOStorage.csv"

#Get Credentials to connect to SharePoint Admin Center
$Cred = Get-Credential

#Connect to SharePoint Online Admin Center
Connect-SPOService -Url $AdminSiteURL -Credential $Cred

#Get all Site collections
$SiteCollections = Get-SPOSite -Limit All
Write-Host "Total Number of Site collections Found:"$SiteCollections.count -f Yellow

#Array to store Result
$ResultSet = @()

Foreach($Site in $SiteCollections)
{
    Write-Host "Processing Site Collection :"$Site.URL -f Yellow
    #Send the Result to CSV 
    $Result = new-object PSObject
    $Result| add-member -membertype NoteProperty -name "SiteURL" -Value $Site.URL
    $Result | add-member -membertype NoteProperty -name "Allocated" -Value $Site.StorageQuota
    $Result | add-member -membertype NoteProperty -name "Used" -Value $Site.StorageUsageCurrent
    $Result | add-member -membertype NoteProperty -name "Warning Level" -Value  $site.StorageQuotaWarningLevel
    $ResultSet += $Result
}

#Export Result to csv file
$ResultSet |  Export-Csv $ReportOutput -notypeinformation

Write-Host "Site Quota Report Generated Successfully!" -f Green

以下是脚本生成的 CSV 文件,用于概述租户中所有网站集的存储使用情况:

[玩转系统] SharePoint Online:使用 PowerShell 获取网站集存储大小 - 配额使用情况报告

使用 PowerShell 获取 SharePoint Online 中的网站集大小:

除了 SharePoint Online Management Shell 之外,您还可以使用 CSOM 方式作为替代方法来检索网站集的存储大小指标。


#Load SharePoint CSOM Assemblies
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\ISAPI\Microsoft.SharePoint.Client.dll"
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"

$SiteURL="https://crescent.sharepoint.com"

#Get Credentials to connect
$Cred= Get-Credential
$Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.Username, $Cred.Password)

#Setup the context
$Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
$Ctx.Credentials = $Credentials
$Site = $Ctx.Site
$Ctx.Load($Site)

#Get Storage Details
$Site.Retrieve("Usage")
$Ctx.ExecuteQuery()
$Site.Usage.Storage

这是获取 OneDrive 网站集存储指标的另一篇文章:使用 PowerShell 获取 OneDrive 网站集存储配额大小

SharePoint Online 网站集大小限制:
默认情况下,站点的最大存储大小限制为 25 TB。但是,您可以按照以下步骤手动设置 SharePoint 存储限制。导航到 SharePoint 管理中心并单击“设置”。单击“设置”页面上的“站点存储限制”,然后切换到“手动”。详细信息:如何在 SharePoint Online 中设置存储限制

使用 PnP PowerShell 在 SharePoint Online 中获取存储配额

让我们使用 PowerShell 检查 SharePoint Online 存储,并使用 PnP PowerShell 获取 SharePoint Online 网站集存储配额的存储分配使用情况和警告级别指标。


#Set Variables
$SiteURL = "https://crescent.sharepoint.com"

#Connect to PnP Online
Connect-PnPOnline -Url $SiteURL -Credentials (Get-Credential)

#Get the Site collection Storage Metrics
Get-PnPTenantSite -Url $SiteURL | Select @{Label="Allocated (GB)";Expression={$_.StorageMaximumLevel/1MB}}, @{Label="Used (MB)";Expression={$_.StorageUsage}},@{Label="Warning Level (GB)";Expression={$_.StorageWarningLevel/1MB}}

同样,要为租户中的所有站点生成站点使用情况报告,请使用:


#Parameters
$AdminCenterURL = "https://crescent-admin.sharepoint.com"
$CSVPath = "C:\Temp\SiteUsageRpt.csv"

Try {
    #Connect to Admin Center   
    Connect-PnPOnline -Url $AdminCenterURL -Interactive
 
    #Get all site usage details
    $Sites = Get-PnPTenantSite  -Detailed | Select *

    $SiteUsageData = @()
    ForEach ($Site in $Sites)
    {
        #Collect site data
        $SiteUsageData += New-Object PSObject -Property ([ordered]@{               
                'Title'                    = $Site.Title
                'URL'                      = $Site.Url
                'Description'              = $Site.Description                    
                'Owner'                    = $Site.OwnerName
                'Storage Quota'            = $Site.StorageQuota
                'Storage MaximumLevel'     = $Site.StorageMaximumLevel 
                'Storage Usage Current'    = $Site.StorageUsageCurrent
                'Resource Quota'           = $Site.ResourceQuota
                'Resource Quota Warning'   = $Site.ResourceQuotaWarningLevel
                'Resource Usage Average'   = $Site.ResourceUsageAverage
                'Resource Usage Current'   = $Site.ResourceUsageCurrent
                'Template'                 = $Site.Template
                'Sharing Capability'       = $Site.SharingCapability
                'Lock Status'              = $Site.LockState
                'Last Modified Date'       = $Site.LastContentModifiedDate
                'Subsites Count'           = $Site.WebsCount
            })
    }
    $SiteUsageData
    #Export Site Usage Data to CSV
    $SiteUsageData | Export-Csv $CSVPath -NoTypeInformation
    Write-Host "Site Usage Report Generated Successfully!" -ForegroundColor Green
}
Catch {
    Write-Host -ForegroundColor Red "Error generating site usage report:" $_.Exception.Message
}

如果您需要检索 SharePoint Online 中子网站的大小,请参阅:使用 PowerShell 获取 SharePoint Online 子网站大小

经常问的问题:

如何查看 SharePoint Online 中文件夹的大小?

导航到站点>>单击“设置”齿轮>>“站点设置”>>单击“站点集管理”下的“存储指标”链接。在存储指标页面上,导航到目标文件夹所在的位置。查看“总大小”列以查找 SharePoint 网站中每个文件夹和文件的大小(包括版本历史记录大小)。
要查看 SharePoint Online 中文件夹的大小,请参阅:如何检查文件夹大小在 SharePoint Online 中?

如何增加我的 SharePoint Online 存储限制?

默认情况下,SharePoint Online 网站存储分配是从存储池自动管理的。如果设置为手动,则增加存储限制的方法如下:登录管理中心>>选择站点>>单击命令栏中的“存储”按钮。在编辑存储限制中,输入“此站点的最大存储空间”。完成后点击“保存”。
更多信息:如何增加 SharePoint Online 网站的存储限制?

如何查找 SharePoint Online 库的大小?

要获取 SharePoint Online 中文档库的大小,请登录到 SharePoint Online 站点 >> 单击“设置”>>“站点设置”>> 单击“存储指标”链接。文档库的存储大小位于“总大小”列下。您还可以使用 PowerShell 获取文档库大小。
详细信息:检查 SharePoint Online 文档库大小

SharePoint Online 库支持的最大文件大小是多少?

250GB!

如何释放 SharePoint Online 上的空间?

要清理 SharePoint Online 网站,请查看第一阶段和第二阶段回收站中的文件、多个版本的文件以及根据保留策略保留在“保留保留库”中的文件。

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

取消回复欢迎 发表评论:

关灯