0

I am working on an enterprise wiki site collection inside sharepoint on-premises 2013, and i want to update a field named "PageNumber", without affecting the modified, modifedby & version number, so i wrote this powershell script and i run it inside a test wiki site:-

$site = get-SPWeb http://**/site/customerwiki/
#specify the list name 
$list = $site.Lists["Customer KB"] 
$listitems = $list.Items 

foreach ($listitem in $listitems) 
{ 
    write-host $listitem["ID"] "processed"
    $listitem["PageNumber"] = $listitem["Initial"]+$listitem["ID"];
    $listitem.SystemUpdate()
    write-host $listitem["Name"] "has been updated." 

} 

where the wiki pages got updated without creating new version or update the modified-by or modified date.. now i am asking this question as i found many articles which mentioned that suing SystemUpdate() will create new versions such as this link:- How to Update SharePoint List Items without Creating New Versions

so can anyone advice on this?

3 Answers 3

1

Use .SystemUpdate(false) which will not create a new version.

SPListItem.SystemUpdate Method

2
  • Hehe, I thought OP was asking how to make sure it does create a new version. Apr 10, 2019 at 21:01
  • @Trevor Seward but in my case if i use .SystemUpdate() without passing any parameters will not create new version as well,,, so is my approach f using .SystemUpdate() without passing any parameters a valid appraoch as well? i got confused as a lot of articles mentioned that using Systemupdate() (without any parameters) will create a new version.. but based on my test it will not
    – John John
    Apr 10, 2019 at 21:16
1

SystemUpdate() is the same as SystemUpdate(false)

SPListItem.SystemUpdate method

Calling this method is the same as calling SystemUpdate(Boolean) with false.

Source: Microsoft Docs. I might be a bit old fashioned, but what is wrong with checking the official documentation? :)

0

You have to pass true as a parameter in order for it to increment the version number:

$listitem.SystemUpdate($true)

MSDN documentation on SystemUpdate().

4
  • now i do not want the SystemUpdate() to create a new version,, and my script is being able to do so,, but i got confused as a lot of articles mentioned that using Systemupdate() (without any parameters) will create a new version.. i hope i have explained my question better..
    – John John
    Apr 10, 2019 at 21:14
  • If you do not want a new version, then Trevor Seward's answer is the correct one. Apr 10, 2019 at 21:16
  • yes i do NOT want to create new version, and based on my test using Systemupdate() (without any parameters) will NOT create new version.. or i have to pass false parameter??
    – John John
    Apr 10, 2019 at 21:18
  • 2
    If through your testing you have found that passing no parameters results in no new version, I would say that seems like a perfectly valid approach. However, it might be a little bit safer to pass $false as a parameter to explicitly tell SharePoint "no, I do not want a new version." That way there is no question what you are telling SharePoint to do. Apr 10, 2019 at 22:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.