【问题标题】:Batch PnP PowerShell command in a recursive function递归函数中的批处理 PnP PowerShell 命令
【发布时间】:2021-02-18 18:20:45
【问题描述】:

目前在 PnP.PowerShell 的 nightly 版本中,我们可以批量处理多个 PnP 请求(如下所述)。

$batch = New-PnPBatch

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

但是,如果我需要从递归函数批处理命令,我们该如何执行呢? 我的要求是在文档库中获取文件夹和子文件夹。代码如下。

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)

如何让上面的代码使用 Batching

【问题讨论】:

    标签: powershell recursion sharepoint-online batching


    【解决方案1】:

    根据文档:https://pnp.github.io/powershell/articles/batching.html

    Get-PnPFolderItem cmd 不支持批处理。

    【讨论】:

      猜你喜欢
      • 2020-09-10
      • 1970-01-01
      • 1970-01-01
      • 2019-11-15
      • 2020-08-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多