How to use PowerShell to get quota information in a usable way

How to use PowerShell to get quota information in a usable way

There are many good resources out there about how to create, modify, & set quotas using PowerShell, that isn’t an issue. Zach Rosenfield has a good post on Managing Bulk Site Collection Quotas in PowerShell and there are dozens of others out there who can give you all of the information about making changes to quotas that you want. My problem was how do I tell what a site’s quota template assignment is and how close they are to the limits using PowerShell rather than having to do a one by one click through the UI?

The Painful Process

You have a number of different quota templates and a reasonable number of site collections in your farm. In order to stay ahead of the curve you want to be able to monitor the growth of your site collections and know when they are heading toward their quota limits. In the UI you will go to Central Administration and visit the Application Management Section where you will find “Configure quotas and locks” as seen below:


Next you will change the Site Collection selector to the site you want and that site’s information will be displayed like this:


Valuable information & the ability to change the quota all in one place. Simple, easily, elegant. Only one problem: you have to do walk through this for EVERY site collection to get the information if you are simply trying to do an audit of the information.

The PowerShell Solution

I searched the blogosphere high and low looking for an answer to this problem. I pinged experts and friends who I expected would have had to solve this solution. The response I got in most cases was “there are pay products that have that functionality” or “I really hadn’t thought about that yet. Let me know when you find an answer”.

Here is what I came up with: (download a copy as a text or PowerShell from GitHub)


The output of this script looks like this:

Url : http://sharepoint2010
Storage Used/1MB : 3
Storage Available Warning/1MB : 0
Storage Available Maximum/1MB : 0
Sandboxed Resource Points Warning : 100
Sandboxed Resource Points Maximum : 300
Quota Name : No Template Applied

Url : http://sharepoint2010/my/personal/spadmin
Storage Used/1MB : 3
Storage Available Warning/1MB : 80
Storage Available Maximum/1MB : 100
Sandboxed Resource Points Warning : 200
Sandboxed Resource Points Maximum : 300
Quota Name : Personal Site

Url : http://sharepoint2010/sites/large
Storage Used/1MB : 0
Storage Available Warning/1MB : 800
Storage Available Maximum/1MB : 1024
Sandboxed Resource Points Warning : 400
Sandboxed Resource Points Maximum : 500
Quota Name : Large Site

Url : http://sharepoint2010/sites/medium
Storage Used/1MB : 0
Storage Available Warning/1MB : 400
Storage Available Maximum/1MB : 500
Sandboxed Resource Points Warning : 200
Sandboxed Resource Points Maximum : 300
Quota Name : Medium Site

This script loops through ALL of your web applications and retrieves information about ALL of your sites.

You can specify a web application to run this against in line 3 just before the pipe. Additionally, if you want to use the script as is you will need to create the text file quotaoutput.txt in your C: root. You can change the name and location of that output file or just remove the “>> c:quotaoutput.txt“ all together and it will merely print to the screen.

This is the information that I found useful. If you want to tweak the script to fit your needs please check out the MSDN articles about SPQuota Members and SPQuotaTemplate Members

Caveat: If you have lots of sites, you might want to consider specifying a web application or a site collection. While I have a dispose statement in here, the script is loading the quotatemplate and spsite information into memory for every site in order to give you the information. This can be a long running operation and take up some significant resources on your server while it is happening. Know your environment and don’t allow this to cause you an issue. I send this information out to a file because I run this over night on my app server and can then look at the information later. The information can be shared with the team who handles support and customer relations so that we can work with the customer to either reduce the size of their site, or raise their quota as needed (usually comes with an additional cost).

Does Storman.aspx solve this issue in SP1?

As of this blog post I have not yet played with SP1 as I am methodically, to my detriment, walking through a complete new build of SharePoint 2010 SP1 on top of SQL 2008 R2 SP1 and Denali CTP3 side by side to do a comparative article (hint on future content). As a result I have been delayed in getting to validate and test this, so the honest answer is I am just not sure yet. Regardless, I know that there are going to be lots of people who will take months to upgrade to SP1 and hopefully this script will be able to help them in the mean time.

Even if Storman.aspx does give a better UI interface, having the text file output of this information is going to be vitally important for better customer support in my opinion.

Credit where credit is due

Shannon Bray, the co-author of one of my current favorite tech books, Automating SharePoint 2010 with Windows PowerShell 2.0, pointed me to a lead in his book that started me on a path and numerous unnamed blog articles each lent a bit to the final answer which you see above. Additionally, two of my co-workers were instrumental in getting me over the last hurdles of this process, Jim Rearick & JJ Willette (supplied the nifty code to get the quota name). Thanks for all of your contributions.

powershell PowerShell Get-QuotaInfo Script from GitHub

notepad Text Get-QuotaInfo file

Comments are closed.