none
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}

    $sum

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

    Wednesday, February 9, 2011 7:58 AM

Answers

  • 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:
    http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spsite.storagemanagementinformation.aspx

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

    Thanks,
    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
    Moderator

All replies