【发布时间】:2021-12-27 19:26:05
【问题描述】:
请有人帮忙解决以下错误?当另一个人字段不为空时,我正在尝试设置 SharePoint 是/否字段。由于某种原因,Set-PnPListItem cmdlet 不接受 ForEach 循环中的 $Item.Id 身份:
#Parameters
$SiteUrl = "https://domain.sharepoint.com/sites/site"
$ListName = "list"
$ListGUID = "5527e75b-40c1-4a89-90a7-035e06f56457"
#Connect to site
Connect-PnPOnline $SiteUrl -Interactive
#Get the List contents
$ListData = (Get-PnPListItem -List $ListName -Id *).FieldValues
#Iterate through each Row in the CSV and import data to SharePoint Online List
ForEach ($Item in $ListData)
{
Write-Host "Checking Item $Item"
$C2T = $False
If($null -ne $($Item."tst_x002f_pg"))
{
$C2T = $True
}
Set-PnPListItem -List $ListGUID -Identity $Item.Id -Values @{"tst_x002f_yn" = "$C2T"}
}
以下是错误:
Get-PnPListItem : Cannot bind parameter 'Id'. Cannot convert value "*" to type "System.Int32". Error: "Input string was not in a correct format."
At C:\Users\%USERNAME%\Documents\PowerShell\UpdateFieldBasedonAnotherField.ps1:10 char:50
+ $ListData = (Get-PnPListItem -List $ListName -Id *).FieldValues
+ ~
+ CategoryInfo : InvalidArgument: (:) [Get-PnPListItem], ParameterBindingException
+ FullyQualifiedErrorId : CannotConvertArgumentNoMessage,PnP.PowerShell.Commands.Lists.GetListItem
Checking Item System.Collections.Generic.Dictionary`2[System.String,System.Object]
Set-PnPListItem : No -Identity has been provided specifying the item to update
At C:\Users\%USERNAME%\Documents\PowerShell\UpdateFieldBasedonAnotherField.ps1:23 char:5
+ Set-PnPListItem -List $ListGUID -Identity $Item.Id -Values @{"tst ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : WriteError: (:) [Set-PnPListItem], PSArgumentException
+ FullyQualifiedErrorId : EXCEPTION,PnP.PowerShell.Commands.Lists.SetListItem
Checking Item System.Collections.Generic.Dictionary`2[System.String,System.Object]
Set-PnPListItem : No -Identity has been provided specifying the item to update
At C:\Users\%USERNAME%\Documents\PowerShell\UpdateFieldBasedonAnotherField.ps1:23 char:5
+ Set-PnPListItem -List $ListGUID -Identity $Item.Id -Values @{"tst ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : WriteError: (:) [Set-PnPListItem], PSArgumentException
+ FullyQualifiedErrorId : EXCEPTION,PnP.PowerShell.Commands.Lists.SetListItem
Checking Item System.Collections.Generic.Dictionary`2[System.String,System.Object]
Set-PnPListItem : No -Identity has been provided specifying the item to update
At C:\Users\%USERNAME%\Documents\PowerShell\UpdateFieldBasedonAnotherField.ps1:23 char:5
+ Set-PnPListItem -List $ListGUID -Identity $Item.Id -Values @{"tst ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : WriteError: (:) [Set-PnPListItem], PSArgumentException
+ FullyQualifiedErrorId : EXCEPTION,PnP.PowerShell.Commands.Lists.SetListItem
Checking Item System.Collections.Generic.Dictionary`2[System.String,System.Object]
Set-PnPListItem : No -Identity has been provided specifying the item to update
At C:\Users\%USERNAME%\Documents\PowerShell\UpdateFieldBasedonAnotherField.ps1:23 char:5
+ Set-PnPListItem -List $ListGUID -Identity $Item.Id -Values @{"tst ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : WriteError: (:) [Set-PnPListItem], PSArgumentException
+ FullyQualifiedErrorId : EXCEPTION,PnP.PowerShell.Commands.Lists.SetListItem
Checking Item System.Collections.Generic.Dictionary`2[System.String,System.Object]
Set-PnPListItem : No -Identity has been provided specifying the item to update
At C:\Users\%USERNAME%\Documents\PowerShell\UpdateFieldBasedonAnotherField.ps1:23 char:5
+ Set-PnPListItem -List $ListGUID -Identity $Item.Id -Values @{"tst ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : WriteError: (:) [Set-PnPListItem], PSArgumentException
+ FullyQualifiedErrorId : EXCEPTION,PnP.PowerShell.Commands.Lists.SetListItem
Checking Item System.Collections.Generic.Dictionary`2[System.String,System.Object]
Set-PnPListItem : No -Identity has been provided specifying the item to update
At C:\Users\%USERNAME%\Documents\PowerShell\UpdateFieldBasedonAnotherField.ps1:23 char:5
+ Set-PnPListItem -List $ListGUID -Identity $Item.Id -Values @{"tst ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : WriteError: (:) [Set-PnPListItem], PSArgumentException
+ FullyQualifiedErrorId : EXCEPTION,PnP.PowerShell.Commands.Lists.SetListItem
Checking Item System.Collections.Generic.Dictionary`2[System.String,System.Object]
Set-PnPListItem : No -Identity has been provided specifying the item to update
At C:\Users\%USERNAME%\Documents\PowerShell\UpdateFieldBasedonAnotherField.ps1:23 char:5
+ Set-PnPListItem -List $ListGUID -Identity $Item.Id -Values @{"tst ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : WriteError: (:) [Set-PnPListItem], PSArgumentException
+ FullyQualifiedErrorId : EXCEPTION,PnP.PowerShell.Commands.Lists.SetListItem
Checking Item System.Collections.Generic.Dictionary`2[System.String,System.Object]
Set-PnPListItem : No -Identity has been provided specifying the item to update
At C:\Users\%USERNAME%\Documents\PowerShell\UpdateFieldBasedonAnotherField.ps1:23 char:5
+ Set-PnPListItem -List $ListGUID -Identity $Item.Id -Values @{"tst ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : WriteError: (:) [Set-PnPListItem], PSArgumentException
+ FullyQualifiedErrorId : EXCEPTION,PnP.PowerShell.Commands.Lists.SetListItem
Checking Item System.Collections.Generic.Dictionary`2[System.String,System.Object]
Set-PnPListItem : No -Identity has been provided specifying the item to update
At C:\Users\%USERNAME%\Documents\PowerShell\UpdateFieldBasedonAnotherField.ps1:23 char:5
+ Set-PnPListItem -List $ListGUID -Identity $Item.Id -Values @{"tst ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : WriteError: (:) [Set-PnPListItem], PSArgumentException
+ FullyQualifiedErrorId : EXCEPTION,PnP.PowerShell.Commands.Lists.SetListItem
Checking Item System.Collections.Generic.Dictionary`2[System.String,System.Object]
Set-PnPListItem : No -Identity has been provided specifying the item to update
At C:\Users\%USERNAME%\Documents\PowerShell\UpdateFieldBasedonAnotherField.ps1:23 char:5
+ Set-PnPListItem -List $ListGUID -Identity $Item.Id -Values @{"tst ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : WriteError: (:) [Set-PnPListItem], PSArgumentException
+ FullyQualifiedErrorId : EXCEPTION,PnP.PowerShell.Commands.Lists.SetListItem
Checking Item System.Collections.Generic.Dictionary`2[System.String,System.Object]
Set-PnPListItem : No -Identity has been provided specifying the item to update
At C:\Users\%USERNAME%\Documents\PowerShell\UpdateFieldBasedonAnotherField.ps1:23 char:5
+ Set-PnPListItem -List $ListGUID -Identity $Item.Id -Values @{"tst ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : WriteError: (:) [Set-PnPListItem], PSArgumentException
+ FullyQualifiedErrorId : EXCEPTION,PnP.PowerShell.Commands.Lists.SetListItem
PS C:\Windows\system32>
如果有人可以提供任何帮助,我将不胜感激。
非常感谢,
亚历克斯。
【问题讨论】:
标签: powershell sharepoint sharepoint-online