pnp / PnP-PowerShell

SharePoint PnP PowerShell CmdLets
https://pnp.github.io/powershell
Other
990 stars 663 forks source link

[BUG] PowerShell 7, I am getting error "Set-PnPListItem: Cannot bind parameter 'Identity'. Cannot convert value "Microsoft.SharePoint.Client.ListItem" to type "SharePointPnP.PowerShell.Commands.Base.PipeBinds.ListItemPipeBind". Error: "Cannot convert the "Microsoft.SharePoint.Client.ListItem" value of type "Deserialized.Selected.System.Management.Automation.PSCustomObject" to type "SharePointPnP.PowerShell.Commands.Base.PipeBinds.ListItemPipeBind"." #2850

Closed guptarajesh001 closed 4 years ago

guptarajesh001 commented 4 years ago

I have used PowerShell 7 version to update list item in the SharePoint online:

Connect-PnPOnline -Url $siteURL -Credentials $SPOCreds Set-PnPListItem -List $listTitle -Identity $listItem -Values @{"Status" = "Started" }

But I am getting error: Set-PnPListItem: Cannot bind parameter 'Identity'. Cannot convert value "Microsoft.SharePoint.Client.ListItem" to type "SharePointPnP.PowerShell.Commands.Base.PipeBinds.ListItemPipeBind". Error: "Cannot convert the "Microsoft.SharePoint.Client.ListItem" value of type "Deserialized.Selected.System.Management.Automation.PSCustomObject" to type "SharePointPnP.PowerShell.Commands.Base.PipeBinds.ListItemPipeBind".

ToddKlindt commented 4 years ago

The error says there's a problem with the value you're passing -Identity. What's the value of $listitem? How does that compare to the values passed to -Identity in the Examples?

guptarajesh001 commented 4 years ago

Thanks, this issue is resolved now, however this code work well with Powershell 5.1,

ToddKlindt commented 4 years ago

Can you post the resolution so that anyone that finds this bug later will benefit from it.

guptarajesh001 commented 4 years ago

Issue in the script : $updateItem = Set-PnPListItem -List $listTitle -Identity $listItem -Values @{"Status" = "Completed" } Resolved by script: Set-PnPListItem -List $listTitle -Identity $listItem.Id -Values @{"Status" = "Completed" }