Created
May 22, 2015 14:24
-
-
Save neilhoff/d6b46ba0f25c1a08b1bb to your computer and use it in GitHub Desktop.
Revisions
-
neilhoff created this gist
May 22, 2015 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,21 @@ # 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