I have a powershell command to update the document title .I want to update the title without changing the modified time. I have used the script $item.SystemUpdate()
But the modified time also changed. Can anyone suggest some better way to do it?
1
2
You can use the PowerShell script below which I have tested and it works well:
# open web
$web = Get-SPWeb http://sp
# get list
$list = $web.Lists["Documents"]
# get item
$item = $list.GetItemById(1)
# disable event firing
$myAss = [Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint");
$type = $myAss.GetType("Microsoft.SharePoint.SPEventManager");
$prop = $type.GetProperty([string]"EventFiringDisabled",[System.Reflection.BindingFlags] ([System.Reflection.BindingFlags]::NonPublic -bor [System.Reflection.BindingFlags]::Static));
$prop.SetValue($null, $true, $null);
# change properties
$item["Title"] = "NewTitle"
# update item (without changing the Modified or Modified By fields)
$item.SystemUpdate($false)
# enable event firing
$prop.SetValue($null, $false, $null);