【问题标题】:Get items in specific folder in Sharepoint online document library with Powershell PNP使用 Powershell PNP 获取 Sharepoint 在线文档库中特定文件夹中的项目
【发布时间】:2020-11-25 08:49:06
【问题描述】:

如何使用 Powershell PNP 获取 Sharepoint 在线文档库中项目的列值? 如果所有文档都在库的根文件夹中,那就太好了。

Connect-PnPOnline –Url https://<company>.sharepoint.com/sites/<Site> –Credentials (Get-Credential)
$Item = Get-PnPListItem -List "SampleList" -Fields "Id","TestColumn"
$Item.FieldValues.TestColumn

但是,我需要查询“SampleList”中存在的子文件夹中的项目。而且这似乎更难。

根据the documentation我可以使用-FolderServerRelativeUrl,

Get-PnPListItem -FolderServerRelativeUrl "/sites/<Site>/Lists/SampleList/Folder1"

但是找不到参数-FolderServerRelativeUrl....

Get-PnPFolderItem : 找不到与参数名称“FolderServerRelativeUrl”匹配的参数

我可以使用其他 cmdlet 的任何想法吗?

【问题讨论】:

    标签: powershell sharepoint-online


    【解决方案1】:

    我很快意识到 Get-PnPListItem 返回所有项目,包括文件夹和子文件夹 :) 所以我最终使用 Where-Object 来过滤项目。

    $Item = Get-PnPListItem -List "SampleList" -Fields "Id","TestColumn" | Where-Object {$_.FieldValues.FileRef -like "*Folder1*"}
    

    【讨论】:

      【解决方案2】:

      我可以调用提到的 cmdlet:

      Get-PnPListItem -List Samples -FolderServerRelativeUrl "/sites/contosomarketing/Lists/Samples/Demo"

      我在我的SP在线环境中测试过:

      测试:

      所以我建议你检查一下“FolderServerRelativeUrl”的值,然后再试一次。

      BR

      【讨论】:

        猜你喜欢
        • 2021-05-05
        • 1970-01-01
        • 2021-03-18
        • 1970-01-01
        • 2020-11-04
        • 1970-01-01
        • 1970-01-01
        • 2010-09-23
        • 2017-09-25
        相关资源
        最近更新 更多