简体   繁体   English

使用 pnp 更新 SharePoint 在线文档库列属性 PowerShell

[英]update SharePoint online document library column property using pnp PowerShell

I need to recursively update properties of folders in SharePoint online document library based on some condition using pnp PowerShell cmdlets.我需要使用 pnp PowerShell cmdlet 根据某些条件递归更新 SharePoint 在线文档库中文件夹的属性。 I could see the cmdlets to update column properties of lists, but not for document library.我可以看到 cmdlet 来更新列表的列属性,但不能用于文档库。

using the below command I fetched all the folders in the library.使用以下命令,我获取了库中的所有文件夹。 How I can update some custom properties?如何更新一些自定义属性?

$folders = Get-PnPFolderItem -FolderSiteRelativeUrl $ParentFolder -ItemType Folder -Recursive

Appreciate your help.感谢你的帮助。

Actually I have found answer for this.其实我已经找到了答案。 the PnPFolderItems command can't handle meta data. PnPFolderItems 命令无法处理元数据。 I could able to change the property values using PnPListItem command.我可以使用 PnPListItem 命令更改属性值。 Check the code below.检查下面的代码。

Connect-PnPOnline -Url $SiteURL -Credentials $Cred

$clientContext = Get-PnPContext
$targetWeb = Get-PnPWeb
$targetList = $targetWeb.Lists.GetByTitle("Documents") # Library Internal Name
$clientContext.Load($targetList)
$clientContext.ExecuteQuery()

$fields = "FileLeafRef","Project" # fields that you need to access and update
$ListItems = Get-PnPListItem -List $targetList -Fields $fields
foreach($ListItem in $ListItems){
    if($ListItem.FileSystemObjectType -eq "Folder"){ # filter folders
        $ListItem["Project"] = "new value to the custom column"
        $ListItem.Update()
    }
}

This code worked for me.这段代码对我有用。 If any better code/cmdlets available for the same, please mention here.如果有任何更好的代码/cmdlet 可用,请在此处提及。

Thank you谢谢

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用PnP PowerShell for SharePoint Online在文档库上设置“说明” - Setting the “Description” on a Document Library using PnP PowerShell for SharePoint Online 使用 Powershell PNP 获取 Sharepoint 在线文档库中特定文件夹中的项目 - Get items in specific folder in Sharepoint online document library with Powershell PNP 需要使用 PnP 在线 SharePoint 中添加语言翻译器 PowerShell - Need to Add Translators for Language in SharePoint Online using PnP PowerShell 使用SharePoint Online PowerShell从模板创建文档库 - Create a Document Library from a Template using SharePoint Online PowerShell PowerShell 用于检索 SharePoint 在线文档库大小 - PowerShell for retrieving SharePoint Online Document Library Size 使用 PoweShell PnP 更新 SharePoint Online 列表中的查找列 - Updating a lookup column in SharePoint Online list using PoweShell PnP Powershell PnP - 在线登录 Sharepoint 并下载文件 - Powershell PnP - login to Sharepoint online and download file 将文档库复制到文档库 sharepoint 在线与 powershell - Copy document library to document library sharepoint online with powershell 使用 Powershell(选项 1 - 使用 PnP.Powershell)将文件上传到 Sharepoint Online (Microsoft 365) - Upload file to Sharepoint Online (Microsoft 365) using Powershell (Option 1-Using PnP.Powershell) PnP 脚本获取 SharePoint 在线文档库的根文件夹并设置唯一权限 - PnP Script to get root folders of a SharePoint online document library and set unique permissions
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM