Modifying a list item field using powershell without changing the following values (modifed/modifiedby/Version)

sharepoint.stackexchange https://sharepoint.stackexchange.com/questions/213534

Вопрос

I have a list which contain the built-in Description field (internal name = comment) which is if type "Rich Text",now i have created a new site column of type "Enhanced Rich Text" named "Custom Description". so i want to copy the content of the current "Description" field which is of type "Rich Text", to be inside the new site column which is of type Enhanced Rich text. and i do not want to change any of these values:-

  1. modified.
  2. modified by
  3. Version

so i wrote this power-shell script :-

$spWeb = Get-SPWeb -Identity "http://****/site/siteA"
$spList = $spWeb.Lists["Tracking"]
$spItem = $spList.GetItemById(6) //will do this for all the fields
$spItem["Custom Description"] = $spItem["Comment"]
$spItem.SystemUpdate()

now using this power-shell script i was able to copy the content of the built-in column "Comment" inside the "Custom Description" and the modified, modifiedby & version did not change... so seems it will achieve what i am looking for

now since i am going to use this power-shell script on all my list items,, so can anyone advice if the above power-shell script can cause any problem i am not aware of?? or it will simply modify the item field safely ?

Это было полезно?

Решение

The SystemUpdate() method is indeed what you are looking for. This method will update the item without changing the Modified, Modified By, and Version fields.

Your PowerShell script will do exactly what you think it is doing, so you can use it without worries.

References:

Лицензировано под: CC-BY-SA с атрибуция
Не связан с sharepoint.stackexchange
scroll top