![](/img/trans.png)
[英]update SharePoint online document library column property using pnp PowerShell
[英]Get items in specific folder in Sharepoint online document library with Powershell PNP
如何使用 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”中存在的子文件夾中的項目。 而這似乎更難。
根據我可以使用的文檔-FolderServerRelativeUrl,
Get-PnPListItem -FolderServerRelativeUrl "/sites/<Site>/Lists/SampleList/Folder1"
但它找不到參數 -FolderServerRelativeUrl....
Get-PnPFolderItem:找不到與參數名稱“FolderServerRelativeUrl”匹配的參數
我可以使用的其他 cmdlet 的任何想法?
我很快意識到 Get-PnPListItem 返回所有項目,包括文件夾和子文件夾:) 所以我最終使用 Where-Object 來過濾項目。
$Item = Get-PnPListItem -List "SampleList" -Fields "Id","TestColumn" | Where-Object {$_.FieldValues.FileRef -like "*Folder1*"}
我可以調用提到的 cmdlet:
Get-PnPListItem -List 示例 -FolderServerRelativeUrl "/sites/contosomarketing/Lists/Samples/Demo"
我在我的SP在線環境中測試過:
測試:
所以我建議你檢查一下'FolderServerRelativeUrl'的值,然后再試一次。
BR
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.