0

I am working as a sharepoint developer and would like to see the size of the content database is now and also need to find out how many sites we have created so far. CAn anyone please help me find out this information. we don't have administrator, but i have admin previlages.

Thanks

user346514
  • 513
  • 4
  • 10
  • 33

2 Answers2

3

If you can run stsadm (as you say in your comment), that means you have admin access, so you can run this in powershell

[Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") | out-null
$prop_Name = [Microsoft.SharePoint.Administration.SPContentDatabase].GetProperty("Name")
$prop_DiskSizeRequired = [Microsoft.SharePoint.Administration.SPContentDatabase].GetProperty("DiskSizeRequired")
$prop_Sites = [Microsoft.SharePoint.Administration.SPContentDatabase].GetProperty("Sites")
[Microsoft.SharePoint.Administration.SPFarm]::Local.Services |? { 
    $_.GetType().FullName -eq "Microsoft.SharePoint.Administration.SPWebService" 
        } |% { 
    $_.WebApplications |% { 
        $_.Name 
        $_.ContentDatabases |% {            
            $prop_Name.GetValue($_, $null)
            $prop_Sites.GetValue($_, $null).Count
            $prop_DiskSizeRequired.GetValue($_, $null)
        }
    } 
}
djeeg
  • 6,685
  • 3
  • 25
  • 28
1
  SPWebService service = SPFarm.Local.Services.GetValue<SPWebService>();
        foreach (SPWebApplication webapp in service.WebApplications)
        {
            Console.WriteLine("WebApplication : " + webapp.Name);
            foreach (SPContentDatabase db in webapp.ContentDatabases)
            {
                Console.WriteLine("{0}, Nb Sites : {1}, Size : {2}, ", db.Name, db.Sites.Count, db.DiskSizeRequired);
            }
        }

note that "DiskSizeRequired" is the amount of disk space that is required for a backup.

Sylvain Reverdy
  • 2,468
  • 3
  • 16
  • 14
  • 1
    Thanks for the reply. Is there any way to find out the information without writing the code? for example using stsadm? – user346514 Feb 15 '11 at 20:28