0

Currently in the nightly version of PnP.PowerShell, we can batch multiple PnP requests(mentioned below).

$batch = New-PnPBatch

1..100 | ForEach-Object{ Add-PnPListItem -List "ItemTest" -Values @{"Title"="Test Item Batched $_"} -Batch $batch }
Invoke-PnPBatch -Batch $batch

But if I need to batch the command from a recursive function how we can perform that? My requirement is to get Folders and Sub Folders in a Document Library. The code is given below.

Function GetFolders($folderUrl)
{
    $folderColl=Get-PnPFolderItem -FolderSiteRelativeUrl $folderUrl -ItemType Folder
    # Loop through the folders
    foreach($folder in $folderColl)
    {
        $newFolderURL= $folderUrl+"/"+$folder.Name
        Write-Host $folder.Name " - " $newFolderURL
        GetFolders($newFolderURL)
    }
}

GetFolders($FolderPath)

How I can make the above code to use Batching

Joseph Jojo John
  • 500
  • 1
  • 7
  • 19

1 Answers1

0

According to the documentation: https://pnp.github.io/powershell/articles/batching.html

Get-PnPFolderItem cmd doesnot support batching.

enter image description here

Michael Han
  • 3,475
  • 1
  • 6
  • 8