Hello,
I am trying to use PowerShell to overwrite my file's modified dates. By accident they were all reset when a few folders were renamed and we primarily use "Open in Explorer" to navigate and open files. Here is the script I have cobbled together. The two problems I am still trying to solve are how to iterate through every file in the document library, and how to edit the modified date. Right now it only runs through the root folder.
$loadInfo1 = [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client") $loadInfo2 = [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client.Runtime") $webUrl = "SITE" $username = "USER" $password = "PASS" | ConvertTo-SecureString -AsPlainText -Force $sourceListName = "Documents" $ctx = New-Object Microsoft.SharePoint.Client.ClientContext($webUrl) $ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($username, $password) $web = $ctx.Web $list = $web.Lists.GetByTitle('Documents') $query = New-Object Microsoft.SharePoint.Client.CamlQuery $items = $list.GetItems($query) $ctx.Load($list) $ctx.Load($items); $ctx.ExecuteQuery() for($j=0; $j -lt $items.Count; $j++) { Write-host "$j["Created"], $itemki["Modified"] " $itemki["Modified"]=$itemki["Last Saved Date"] $itemki[$j].UpdateOverwriteVersion() }
Thank you in advance for any help!