Contents

Update specific list items in SharePoint with PowerShell

In this post, we’ll 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

Below you can see how the original item’s version was (3.0), and how it changed after running the command with -UpdateType Update. This is what you would normally expect when updating an item, the version increments.

/images/powershell-screenshots/update-items-img1.png

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

/images/powershell-screenshots/update-items-img2.png

UpdateType SystemUpdate or UpdateOverwriteVersion

The starting point being the screenshot above (with version 4.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

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

/images/powershell-screenshots/update-items-img3.png

Version
The Title has been amended, but the version is still the same as before.