We have a requirement to get the list of all the Site
collections along with their Site quotas.
Below Windows PowerShell script will output the following
information,- Site URL
- Assigned/Allocated Site Quota Size
- Total Storage User
You can copy the below script into a notepad and edit the OutputFile and Siteurl as needed in your environment save the file as Script.PS1. You can also paste the code
in the SharePoint 2010 Management Shell. (Keep in mind to run as Administrator)
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
#Configure the
location for the SiteCollectionQuota output file$OutputFile="C:\SiteCollectionsQuota.csv";
"Site URL"+","+"Quota Limit (MB)"+","+"Total Storage Used (MB)"+"" | Out-File -Encoding Default -FilePath $OutputFile;
#Specify the root site collection within the Web app
$Siteurl="Your web application URL";
$Rootweb=New-Object Microsoft.Sharepoint.Spsite($Siteurl);
$Webapp=$Rootweb.Webapplication;
#Loops through each site collection within the Web app
Foreach ($Site in $Webapp.Sites)
{if ($Site.Quota.Storagemaximumlevel -gt 0) {[int]$MaxStorage=$Site.Quota.StorageMaximumLevel /1MB} else {$MaxStorage="0"};
if ($Site.Usage.Storage -gt 0) {[int]$StorageUsed=$Site.Usage.Storage /1MB};
if ($Storageused-gt 0 -and $Maxstorage-gt 0){[int]$SiteQuotaUsed=$Storageused/$Maxstorage* 100} else {$SiteQuotaUsed="0"};
$Web=$Site.Rootweb; $Site.Url + "," +$MaxStorage+","+$StorageUsed | Out-File -Encoding Default -Append -FilePath $OutputFile;$Site.Dispose()};
No comments:
Post a Comment