Script to figure out site collections which are crossed storage quota

sns 9,226 Reputation points
2021-02-19T16:46:55.567+00:00

Do we have script to pull the list of site collections which are crossed storage and giving a warning when browsing site.

Here I need list of those storage crossed/warning site collections from targeted set of site collections. Those targeted site collections number between 30 to 40.

Example : if I enter 30 site collections in input file and I should get list of those storage effected site collections in the output Please help.

Thank you.

SharePoint Server Management
SharePoint Server Management
SharePoint Server: A family of Microsoft on-premises document management and storage systems.Management: The act or process of organizing, handling, directing or controlling something.
2,889 questions
0 comments No comments
{count} votes

Accepted answer
  1. Emily Du-MSFT 43,831 Reputation points Microsoft Vendor
    2021-02-22T11:10:26.397+00:00

    @sns
    1.Go to Central Administration -> Application Management -> Configure quotas and locks -> Select the site collection -> Set the value of "Send warning e-mail when site storage reaches".
    70643-3.png
    2.Create an input csv file with site collection URLs.
    70653-1.png
    3.Run below PowerShell.

    if ((Get-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue) -eq $null)     
                    {    
                        Add-PSSnapin "Microsoft.SharePoint.PowerShell"    
                    }    
    
                    $results = @()    
    
                    $csv = Import-Csv "the local path of csv file, such as C:\sites.csv"  
                    $a = $csv.Url  
    
                    try     
                    {    
                      foreach ($_ in $a)    
                      {    
                      $Site = Get-SPSite $_  
    
                                 $RowDetails = @{    
                                      "Site URL"                            = $site.Url    
                                      "Storage Used"                        = $site.Usage.Storage/1MB    
                                      "Storage Available Warning"           = $site.Quota.StorageWarningLevel/1MB    
                                      "Storage Available Maximum"           = $site.Quota.StorageMaximumLevel/1MB    
                                    }    
                          $results += New-Object PSObject -Property $RowDetails    
                          $site.Dispose()     
                        }     
                    }     
    
                    catch    
                    {            
                       $e = $_.Exception    
                       $line = $_.InvocationInfo.ScriptLineNumber    
                       $msg = $e.Message     
    
                       Write-Host -ForegroundColor Red "caught exception: $e at $line"    
                       Write-Host $msg    
                       write-host "Something went wrong"    
                    }     
    
                    $results | Export-csv -Path "C:\SiteQuotaDetailedInfo.csv" -NoTypeInformation    
                    Write-Host "-------------------- Completed! -----------------------------"  
    

    70565-2.png

    4.Compare "Storage Used" with "Storage Available Warning" in the output csv file.


    If an Answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


0 additional answers

Sort by: Most helpful