Powershell to get Size of Document Library or Folder RRS feed

  • Question

  • I want to use Powershell to get the size of a document library (or a folder).

    Can you please tell me how I can get the size?

    What I have done so far is

    Start-SPAssignment -Global

    $site = Get-SPSiteAdministration -Identity "http://mysite"

    $site.RootWeb.Folders[0].Files | %{$sum += $_.Length}


    But I am not sure if this is really returning any sensible data to me.

    Wednesday, February 9, 2011 7:58 AM


  • Hi MSDN Student,

    The space used for a document library is equal to to the sum of the files in the document library. So the script you used will works well. There is a similar method in the article Radi posted, which is used to sum the total size of a folder too.

    Another possible solution is involve Microsoft.SharePoint in the PowerShell, and use the StorageManagementInformation method to get the document library's size.

    For more informatino about StorageManagementInformation, please see:

    If you have any more questions, please feel free to ask.

    Jin Chen

    Jin Chen - MSFT
    • Marked as answer by MSDN Student Thursday, February 10, 2011 10:10 AM
    Thursday, February 10, 2011 9:30 AM

All replies