powershell
powershell copied to clipboard
[BUG] Set-PnPListItem -Batch with -UpdateType UpdateOverwriteVersion updates Modified Date
Reporting an Issue or Missing Feature
Set-PnPListItem updates the Modified Date when using the Batch parameter. Note: The function works correctly (retains the Modified Date) when omitting the Batch parameter.
Expected behavior
Modified Date should not change when using the UpdateOverwriteVersion UpdateType Version number stays the same
Actual behavior
Modified Date changes to the current date (incorrect behavior) Version number stays the same (correct behavior)
Steps to reproduce behavior
Requires PowerShell 7.2.3 or higher
$SiteURL = "https://prefix.sharepoint.com/sites/SiteName" $ListName= "DocumentLibraryName"
Connect-PnPOnline -Url $SiteURL -UseWebLogin
$batch = New-PnPBatch Set-PnPListItem -List $ListName -Identity 1 -Batch $batch -UpdateType UpdateOverwriteVersion -Values @{"Author"="[email protected]";"Editor"="[email protected]"} Invoke-PnPBatch -Batch $batch
What is the version of the Cmdlet module you are running?
1.10.0
Which operating system/environment are you running PnP PowerShell on?
- [ x] Windows
Hi @RRFreemanArchitect , @veronicageek - looks like this is by design.
If you dont want to update the Modified date, then use SystemUpdate
https://thesharepoint2010.wordpress.com/2012/09/26/update-systemupdate-and-updateoverwriteversion-splistitem/
@gautamdsheth - Hmmm... I'm not sure. Because it works OK with -UpdateOverwriteVersion
without the -Batch
. And your article is from 2012 😅
SystemUpdate is another option which does not allow you to change the Modified By field.
I am updating the Modified By field and must use the UpdateOverwriteVersion option which works correctly without the -Batch flag, so this is not working as designed.
Issue still happening with 1.11.81
@veronicageek / @RRFreemanArchitect - so maybe CSOM behavior has changed. When it comes to using batching, we always follow this behavior. Don't think it is a bug here.
Check from this link: https://pnp.github.io/pnpcore/using-the-sdk/listitems-intro.html#updating-list-items
@gautamdsheth / @veronicageek - You may be correct that this is a bug in the CSOM call but the pnp powershell documentation does not mention the inconsistency between batch and non-batched calls Looking at the code I believe this CSOM call has the bug: item.UpdateOverwriteVersionBatch(Batch.Batch)
We need to either fix this bug (via a CSOM bug fix request) or document the bug in the documentation you referenced.
This issue is stale because it has been open 14 days with no activity. Remove stale label or comment or this will be closed in 5 days
@RRFreemanArchitect - If your issue is still present, can you try with the latest nightly please. Note that if you're still on PS5 it will be 1.12.80
, otherwise just run the usual which will be 2.0.x
Thanks
Closing as no response.