如何解决递归函数中的批处理 PnP PowerShell 命令
目前在 PnP.PowerShell 的夜间版本中,我们可以批量处理多个 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)
如何让上面的代码使用批处理
解决方法
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。