Created
May 22, 2015 14:24
-
-
Save neilhoff/d6b46ba0f25c1a08b1bb to your computer and use it in GitHub Desktop.
SharePoint 2013: Get the size and content database for all site collections in a web application
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Iterate through all site collections in a SharePoint web application and output to a CSV file: | |
# - Site, Size(B), Size(MB), Size(GB), Content database | |
$webApp = 'http://webappurl' | |
$csvPath = 'e:\data.csv' | |
# Get all the sites in the web app | |
$sites = Get-SPWebApplication $webApp | Get-SPSite -Limit ALL | |
# Set the header for the file | |
$data = "Site, Size(B), Size(MB), Size(GB), Content Database" | |
# Loop through each site pulling the data needed appending to $data | |
Foreach($site in $sites){ | |
$mb = "{0:F2}" -f($site.Usage.Storage/1024/1024) | |
$gb = "{0:F2}" -f($mb/1024) | |
$data += "`n" + $site.url + ", " + $site.Usage.Storage + ", " + $mb + ", " + $gb + ", " + $site.ContentDatabase.Name | |
} | |
# Output the data to the file | |
$data | out-file $csvPath |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment