Get sharpoin library size


The below script can be Usedthe to check the size of SharePoint Library.  you have to pas the Web URL.  With litle change in the script you can make it for site collection.

function Get-SPListSize
{
    [CmdletBinding()]
    [OutputType([int])]
    Param
    (
        # Param1 help description
        [Parameter(Mandatory=$true,
                   ValueFromPipeLine=$true,
                   ValueFromPipelineByPropertyName=$true,
                   Position=0)]
        [validteNoNull()]
        [Microsoft.SharePoint.SPWeb]$Web
    )

    Begin
    {
    }
    Process
    {
       foreach($List in $web.Lists)
       {
            if($list-isnot [Microsoft.SharePoint.SPDocumentLibrary]) {contine}
            $size = 0
            foreach($item in $list.Items)
            {
                $size = $item.File.Length
                foreach($version in $item.Versions)
                {
                    $size += $version.Size
                }
            }
            $data = @{"List" = $list.RootFolder.ServerRelativeUrl
                      "Size" = $size
                      "Size (MB)" = "{0:0:00}" -F ($size / 1MB)
                      "Size (GB)" = "{0,0,00}" -F ($size / 1GB)
                      }
            $o = New-Object -TypeName PSObjet -Property $data
            Write-Output $o

       }

    }
    End
    {
    }
}