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
    {
    }
}
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s