Thu. Jun 16th, 2022
Function Get-AllFileSizeFromRoot($web, $ctx, [String]$RelativeUrl, [Microsoft.SharePoint.Client.File]$File)
{
    $FileRelativeUrl = $RelativeUrl + "/" + $File.Name
    #Get the Checked out File data
    $File = $Web.GetFileByServerRelativeUrl($FileRelativeUrl)
    $Ctx.Load($File)
    $Ctx.Load($File.Versions)
    $Ctx.ExecuteQuery()
    $FileSize =0; $VersionSize = 0
    If($File.Versions.Count -ge 1)
    {
        $VersionSize = $File.Versions | Measure-Object -Property Size -Sum | Select-Object -expand Sum
    }
    $FileSize =  $File.Length  + $VersionSize
    $TotalSize = $TotalSize + $FileSize
    $TotalSize =  [Math]::Round($TotalSize/1MB, 2)
    Write-host "Total Size of the File '$($File.Name)' : $TotalSize"
    $Global:ListSize = $Global:ListSize + $TotalSize
}

This website uses cookies. By continuing to use this site, you accept our use of cookies.