SharePoint 2010–Powershell to dump out the Site Collection Storage Usage for a Farm

Recently I was working for a company with a lot of site collections and they wanted to look at some of the usage stats and other relevant information about how the site collections are being utilized on the farm.  This is actually very easy to do utilizing PowerShell because we can “Get-SPSiteAdministration” and then write out the information in a nice table format.

First step is to get the SPSiteAdministration into an object variable that we can run get-members on so we know what is exposed to us for reporting purposes (Note: Use Get-SPSiteAdministration instead of Get-SPSite because we want to report on stuff in the farm that we may not be site collection admins of like mySites)

$sc = Get-SPSiteAdministration –Identity http://SiteCollection

$sc | Get-Member

You’ll get a nice output like the following, I’ve highlighted what we are interested in:

TypeName: Microsoft.SharePoint.Administration.SPSiteAdministration

Name                      MemberType Definition

—-                      ———- ———-

AddWeb                    Method     System.Void AddWeb(string strWebUrl, string strTitle, string strDescription, Sy…

ApplyWebTemplate          Method     System.Void ApplyWebTemplate(string strWebTemplate)

Delete                    Method     System.Void Delete(), System.Void Delete(bool bDeleteADAccounts), System.Void D…

Dispose                   Method     System.Void Dispose()

Equals                    Method     bool Equals(System.Object obj)

GetHashCode               Method     int GetHashCode()

GetType                   Method     type GetType()

ToString                  Method     string ToString()

AdministrationSiteType    Property   Microsoft.SharePoint.SPAdministrationSiteType AdministrationSiteType {get;set;}

AverageResourceUsage      Property   System.Double AverageResourceUsage {get;}

CurrentResourceUsage      Property   System.Double CurrentResourceUsage {get;}

Description               Property   System.String Description {get;}

DiskUsed                  Property   System.Int64 DiskUsed {get;}

LockIssue                 Property   System.String LockIssue {get;set;}

OwnerEmail                Property   System.String OwnerEmail {get;}

OwnerLoginName            Property   System.String OwnerLoginName {get;set;}

Quota                     Property   Microsoft.SharePoint.Administration.SPQuota Quota {get;set;}

ReadLocked                Property   System.Boolean ReadLocked {get;set;}

ReadOnly                  Property   System.Boolean ReadOnly {get;set;}

RootWebProvisioned        Property   System.Boolean RootWebProvisioned {get;}

RootWebTemplate           Property   System.String RootWebTemplate {get;}

SecondaryContactLoginName Property   System.String SecondaryContactLoginName {get;set;}

SiteSubscription          Property   Microsoft.SharePoint.SPSiteSubscription SiteSubscription {get;}

Title                     Property   System.String Title {get;}

Url                       Property   System.String Url {get;}

UsersCount                Property   System.Int32 UsersCount {get;}

WriteLocked               Property   System.Boolean WriteLocked {get;set;}

 

From here it’s just a matter of putting together a PowerShell Script that will grab all the site collections in the farm

Get-SPSiteAdministration

piped into a selection so we can print out the amount of disk used and users:

Get-SPSiteAdministration | select Url, DiskUsed, UsersCount

if you’re dealing with a large amount of SiteCollections here is where you tack on the –Limit All to the Get-SPSiteAdministration and of course you’ll want to add some table formatting, and I’m assuming if you’re looking at this information what you really care about are the biggest sites:

Get-SPSiteAdministration -Limit All | select Url, DiskUsed, UsersCount | Sort-Object -Descending -Property "DiskUsed" | Format-Table –AutoSize

Of course, you’ll probably want to include the amount of DiskUsed in Megabytes

Get-SPSiteAdministration -Limit All | select Url, @{label = "Size";Ex = {$_.DiskUsed/1MB}}, UsersCount | Sort-Object -Descending -Property "Size" | Format-Table –AutoSize

Or write it out to an .html file for nicely formated web viewing:

Get-SPSiteAdministration -Limit All | select Url, @{label = "Size";Ex = {$_.DiskUsed/1MB}}, UsersCount | Sort-Object -Descending -Property "Size" | ConvertTo-Html -title "Site Collections" | Set-Content sc.html

And there you have it, a nice way for a farm admin to report on all the disk usage and user information lists in their farm

6 thoughts on “SharePoint 2010–Powershell to dump out the Site Collection Storage Usage for a Farm”

  1. Hi Randy – which script are you refering to?

    In order for this to run, you should be on a server that hosts the farm and open the SharePoint Management PowerShell window.

    First try running the “get-SPSiteAdministration” commandlet to make sure everything connects, and then just keep going down the list until you get to one that doesn’t work. That being said I just went through and verified that the scripts work on a farm with the following:

    Major Minor Build Revision
    —– —– —– ——–
    14 0 6137 5002

Leave a Reply