Pnp list item

Please may someone help with the below error? I'm trying to set a SharePoint yes/no field when another person field is not blank. For some reason the Set-PnPListItem cmdlet isn't accepting the $Item.Id identity within the ForEach loop:

#Parameters $SiteUrl = "//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"} }

And here are the errors:

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>

I'd appreciate any help anyone could give.

Many thanks,

Alex.

Video liên quan

Chủ Đề