{"id":2134,"date":"2017-01-05T07:43:01","date_gmt":"2017-01-05T07:43:01","guid":{"rendered":"https:\/\/poiseddevelopers.com\/reality-tech\/?p=2134"},"modified":"2024-04-26T12:20:17","modified_gmt":"2024-04-26T12:20:17","slug":"restore-sharepoint-document-timestamp-and-author-from-feedfile","status":"publish","type":"post","link":"https:\/\/poiseddevelopers.com\/reality-tech\/restore-sharepoint-document-timestamp-and-author-from-feedfile\/","title":{"rendered":"Restore SharePoint document timestamp and author from feedfile"},"content":{"rendered":"<p>Often an administrator during maintenance or checking in a document for a user, \u201cstomps\u201d on a timestamp and who edited the document. In a perfect world we take the time to restore authorship and timestamp. Here\u2019s a script that reads in a CSV of the URL, timestamp and user of any number of documents to correct. it will also try to remove the previous incorrect version, if possible.<\/p>\n<pre style=\"overflow-x: scroll; width: 50%;\" lang=\"php\"> \r\n$actionlist= Import-Csv \"C:scriptsNameDateTag.csv\"\r\n \r\nfor ($Ai=0; $Ai -lt $actionlist.Count; $Ai++)\r\n    {\r\n    $ActionRow=$ActionList[$Ai]\r\n    $docurl=$ActionRow.DocURL;\r\n    $site = New-Object Microsoft.SharePoint Online.SPSite($docurl)\r\n    $web = $site.OpenWeb()\r\n    $item = $web.GetListItem($docurl)\r\n    $list = $item.ParentList\r\n     \r\n    [System.DateTime] $dat = Get-Date $ActionRow.Timestamp\r\n    $usr = $web.ensureuser($ActionRow.Editor)\r\n     \r\n     $item[\"Modified\"] = $dat;\r\n     $item[\"Editor\"] = $usr;\r\n        $item.Update()\r\n     try { $item.Versions[1].delete() } catch {write-host -foregroundcolor red \"Error (1) could not delete old version of $($item['Name'])\"}\r\n    }\r\n\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Often an administrator during maintenance or checking in a document for a user, \u201cstomps\u201d on a timestamp and who edited the document. In a perfect world we take the time to restore authorship and timestamp. Here\u2019s a script that reads in a CSV of the URL, timestamp and user of any number of documents to [&hellip;]<\/p>\n","protected":false},"author":7,"featured_media":2135,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[26],"tags":[],"class_list":["post-2134","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-powershell"],"acf":[],"_links":{"self":[{"href":"https:\/\/poiseddevelopers.com\/reality-tech\/wp-json\/wp\/v2\/posts\/2134","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/poiseddevelopers.com\/reality-tech\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/poiseddevelopers.com\/reality-tech\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/poiseddevelopers.com\/reality-tech\/wp-json\/wp\/v2\/users\/7"}],"replies":[{"embeddable":true,"href":"https:\/\/poiseddevelopers.com\/reality-tech\/wp-json\/wp\/v2\/comments?post=2134"}],"version-history":[{"count":1,"href":"https:\/\/poiseddevelopers.com\/reality-tech\/wp-json\/wp\/v2\/posts\/2134\/revisions"}],"predecessor-version":[{"id":2136,"href":"https:\/\/poiseddevelopers.com\/reality-tech\/wp-json\/wp\/v2\/posts\/2134\/revisions\/2136"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/poiseddevelopers.com\/reality-tech\/wp-json\/wp\/v2\/media\/2135"}],"wp:attachment":[{"href":"https:\/\/poiseddevelopers.com\/reality-tech\/wp-json\/wp\/v2\/media?parent=2134"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/poiseddevelopers.com\/reality-tech\/wp-json\/wp\/v2\/categories?post=2134"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/poiseddevelopers.com\/reality-tech\/wp-json\/wp\/v2\/tags?post=2134"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}