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()
    }
}