Update Specific List Items in SharePoint using PowerShell PnP

In this blog post, let’s have a look at a specific cmdlet: Set-PnPListItem.
We have a couple of interesting parameters (including the -Batch one!!), depending on what we’re trying to do. If you used this cmdlet before, and particularly to update something without creating a new version of the file, we used the -SystemUpdate parameter which I’ve found great and really useful.

Now we have new ones which are under -UpdateType:

  • Update: Sets field values and creates a new version if versioning is enabled for the list
  • SystemUpdate: Sets field values and does not create a new version. Any events on the list will trigger.
  • UpdateOverwriteVersion: Sets field values and does not create a new version. No events on the list will trigger.

It’s important to pay attention to what each of those are doing. In a nutshell, Update will create a new version, and the last two (SystemUpdate & UpdateOverwriteVersion) will not BUT if you have flows or any automation attached to them, you’d want to choose the correct one.

 

-UpdateType Update

Before running the command

 

 

 

 

 

 

 

Set-PnPListItem -List "PnP List" -Identity 1 -Values @{"Title" = "HelloWorld123"} -UpdateType Update

 

After running the command

 

-UpdateType SystemUpdate or UpdateOverwriteVersion

the starting point being the screenshot above (with version 10.0), running one or the other (SystemUpdate or UpdateOverwriteVersion) will have same effect if you have no flows or automation attached to the item. If you do, and you don’t want it to be triggered, used -UpdateType UpdateOverwriteVersion

Set-PnPListItem -List "PnP List" -Identity 1 -Values @{"Title" = "HelloWorld456"} -UpdateType UpdateOverwriteVersion

Title has changed but NOT the version

Thanks for reading! 🙂

 

 

Leave a Reply

%d bloggers like this: