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
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.
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.
UpdateType SystemUpdate or UpdateOverwriteVersion
The starting point being the screenshot above (with version
4.0), running one or the other
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