Reporting on Site Collection and storage information
Wouldn’t it be nice to have a single report of Site Collections, the Content Database each is in, and the size in GB? Well, let’s do it!
First let’s grab the Web Application:
get-spwebapplication http ://SharePoint Then we grab the Site Collections (all of them): [sourcecode language="powershell"] Get-SPSite -Limit all
Now, let’s select the information we want to see in the report:
select url,contentdatabase
Let’s calculate the size in Gigabytes:
select url,contentdatabase,@{label="Size in GB";Expression={$_.usage.storage/1GB}}
Now, let’s output the report to a CSV file, making it easy to read in Excel:
convertto-csv | set-content "L:PowerShellDBsize.csv"
Now let’s put it all together in a single command, piping the commands to produce the report:
get-spwebapplication http ://SharePoint | Get-SPSite -Limit all | select url,contentdatabase,@{label="Size in GB";Expression={$_.usage.storage/1GB}} | convertto-csv | set-content "L:PowerShellDBsize.csv"