Skip to content

[BUG] Set-PnPListItem doesnt work with batching "Cannot find item with Identity PnP.PowerShell.Commands.Base.PipeBinds.ListItemPipeBind" #3334

Open
@Smevs

Description

@Smevs

When using the -batch parameter with Set-PnPListItem, it fails with the following error:

"Cannot find item with Identity PnP.PowerShell.Commands.Base.PipeBinds.ListItemPipeBind"

For example, this works (no batching):

$targetFolder = "Path/To/Folder"
ForEach ($folder in $folders) {
$folderUpload = Add-PnPFolder -Name $folder.FileLeafRef -Folder $targetFolder -Connection $DestinationConnection
$metaData = @{
"Created" = $folder.Created_x0020_Date
}
# Set Metadata on folder just created
Set-PnPListItem -List $DestinationLibrary -Identity $folderUpload.ListItemAllFields -Values $metaData -Connection $DestinationConnection
}

Whereas, this does not, just gives error:

$targetFolder = "Path/To/Folder"
$batch = New-PnPBatch -Connection $DestinationConnection
ForEach ($folder in $folders) {
$folderUpload = Add-PnPFolder -Name $folder.FileLeafRef -Folder $targetFolder -Connection $DestinationConnection
$metaData = @{
"Created" = $folder.Created_x0020_Date
}
# Set Metadata on folder just created
Set-PnPListItem -List $DestinationLibrary -Identity $folderUpload.ListItemAllFields -Values $metaData -Batch $batch -Connection $DestinationConnection
}
Invoke-PnPBatch -Batch $batch -Connection $DestinationConnection

I believe this has been the case since batching was introduced, and i have personally experienced it in versions 1.9, 1.11, 1.12 (With PS 5.1), 2.0, and now 2.2 (with PS 7.3.5)

Expected behavior

Items to be batched as per documentation to reduce API calls

Actual behavior

Each time Set-PnPListItem is called, it gives this error:

Set-PnPListItem -List $DestinationLibrary -Identity $folderUp …
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| Cannot find item with Identity PnP.PowerShell.Commands.Base.PipeBinds.ListItemPipeBind
Set-PnPListItem:

Steps to reproduce behavior

See code above

What is the version of the Cmdlet module you are running?

2.2 but also experienced in older versions as mentioned above

Which operating system/environment are you running PnP PowerShell on?

  • Windows
  • Linux
  • MacOS
  • Azure Cloud Shell
  • Azure Functions
  • Other : please specify

This issue has been raised a few times previously, see issues 2184, 2191 and partially related 1863. But it has been closed/unanswered each time with no resolution.

Thanks for your time.

Metadata

Metadata

Assignees

No one assigned

    Labels

    batch issueIssues where the -Batch method is causing the problembugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions