首页 > 解决方案 > 传递托管元数据术语数组时,set-pnplistitem 出错

问题描述

使用 pnp powershell 修改 sharepoint 在线列表项,我正在尝试更新现有列表项,添加一组托管元数据术语,但是当我尝试使用多个术语更新条目时,该命令一直失败。或者,如果我传递一个带有单个术语的数组变量。

set-pnplistitem -list "Pages" -Identity $itemID -values @{"Category"=("How-To")} -SystemUpdate #WORKS
set-pnplistitem -list "Pages" -Identity $itemID -values @{"Category"=("For Teams That Create Digital Content")} -SystemUpdate #WORKS
set-pnplistitem -list "Pages" -Identity $itemID -values @{"Category"=("How-To","For Teams That Create Digital Content")} -systemUpdate #FAILS
$test=@("How-To")
set-pnplistitem -list "Pages" -Identity $itemID -values @{"Category"=$test} -SystemUpdate # FAILS
$test=@("How-To","For Teams That Create Digital Content")
set-pnplistitem -list "Pages" -Identity $itemID -values @{"Category"=$test} -SystemUpdate # FAILS

error:
set-pnplistitem : Object reference not set to an instance of an object.
At C:\Powershell\test.ps1:120 char:13
+             set-pnplistitem -list "Pages" -Identity $itemID -va ...
+             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : WriteError: (:) [Set-PnPListItem], NullReferenceException
+ FullyQualifiedErrorId : EXCEPTION,SharePointPnP.PowerShell.Commands.Lists.SetListItem

我做错了吗,还是 set-pnpListItem 有错误?

标签: powershellsharepoint-online

解决方案


推荐阅读