다음을 통해 공유


PowerShell Script to Find Site Collections not Using a Storage Quota

You may come across situations where you need to know which site collections in your farm are not using one of the farm storage quotas. The script below will find and output these sites.

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

#Get available quota templates in farm
$Templates = [Microsoft.SharePoint.Administration.SPWebService]::ContentService.QuotaTemplates

#Loop through wach web app
foreach($webApp in Get-SPWebApplication)
{
    #Loop through each site in the web app to check quota
    foreach($site in $webApp.Sites)
    {
        $currentQuotaID = $site.Quota.QuotaID
        $quotaFound = $false
       
        #Loop through each quota template in the farm looking for a mact in IDs
        foreach($Template in $Templates)
        {
            #If there is a macth found, break out of the loop and move on to the next site
            if($currentQuotaID -eq $Template.QuotaID)
            {
                $quotaFound = $true
                break
            }
        }
       
        #If no match is found, output it
        if($quotaFound -eq $false)
        {
            Write-Host ("No quota found for " + $site.URL + ". QuotaID: " + $currentQuotaID)
        }
        $site.Dispose()
    }
}

Comments

  • Anonymous
    February 04, 2016
    Nice.. one Thanks...
  • Anonymous
    April 03, 2017
    This returns any site that does not use a quota TEMPLATE. If the site uses an individual quota, it's also returned. I'm trying to return all site collections that do not use any quota at all (template or individual quota). Also, as you readers likely know, you can dump output to a text file by running it as a ps1 and adding >Drive:\path\OutputFileName.txt