Sometimes, mostly during PoC or testing policies like retention policy or lifecycle policy you would need some documents created and updated weeks, months or even years ago.
But if you create or upload a document in SharePoint library – it will be just a regular new document. So, how to get old documents in the new environment?
I see two options:
- Sync with OneDrive
If you sync a library with your local folder (done Microsoft by OneDrive desktop app) and put some old document in your synced folder – the doc will be synchronized back to SharePoint library with Created and Modified properties preserved. - Make the document older with PowerShell
With “Set-PnPListItem” PowerShell command you can update not only such properties like Title, but also “Created By”, “Modified By” and even date and time document was created and modified via “Created” and “Modified”.
Optionally you can play with document history with “-UpdateType” parameter.
UpdateType possible values are:- Update: Sets field values and creates a new version if versioning is enabled for the list
- SystemUpdate: Sets field values and does not create a new version. Any events on the list will trigger.
- UpdateOverwriteVersion: Sets field values and does not create a new version. No events on the list will trigger