Tue. Jan 4th, 2022
Function Get-FileSizeFromLargeList($web,$ctx,$List)
{

 Try{
        write-host  $List.title "exceeds the list view threshold, Item Count - $($List.itemCount )"
        $Timestamp = GetTimeStamp
        $Ctx.Load($List.RootFolder)
        $Ctx.ExecuteQuery()
        $ListServerRelativeUrl  =  $list.RootFolder.ServerRelativeUrl
        $folderCol = $list.RootFolder.Folders;
        $Ctx.Load($folderCol)
        $Ctx.ExecuteQuery() 

        $fileCol = $list.RootFolder.files;
        $Ctx.Load($fileCol)
        $Ctx.ExecuteQuery() 

        foreach($f in $fileCol)
        {
            Get-AllFileSizeFromRoot -web $web -ctx $ctx -List $List -RelativeUrl $ListServerRelativeUrl -file  $f 
            $Global:FileCounter++
        }

        foreach($folder in $folderCol)
        {
            $RelativeUrl = $ListServerRelativeUrl #+ "/" + $folder.Name 
            Get-AllFileSizeFromFolder -web $web -ctx $ctx -RelativeUrl $RelativeUrl -Folder $folder 
            $Global:FolderCounter++
        }

 }Catch
 {

    $e = $_.Exception
    $line = $_.InvocationInfo.ScriptLineNumber
    $msg = $e.Message 
    Write-Host -ForegroundColor Red "caught exception: $e at $line" 
    write-host -f Red "Error - Get-FileSizeFromLargeList" $_.Exception.Message 
 }
}

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