Forum Discussion

catereilly's avatar
catereilly
Copper Contributor
Aug 01, 2025
Solved

can PnpOnline script move files to a different library and retain same created and modified dates?

Hi there,  Is it possible to move Sharepoint files to a different library and retain the created & modified dates using a PowerShell script?  I've only been able to do it with a PowerAutomate flow which is tedious to set up.  The method I'm trying with the PowerShell script downloads the file temporarily and then uploads it but treats it as a new file - which it is - and even with steps to match the metadata - which works for all other custom columns doesn't seem to work for modified and created date fiels.  I've also gone down the path of TEST API call - doesn't error but doesn't achieve end goal of moving over the created and modified dates from original file.  Any pointers would be greatfully appreciated.  Am I wasting my time and should I give up and use PowerAutomate?

  • The Move-PnPFile command automatically preserves metadata such as creator and time during migration.

4 Replies

  • The best way to move files between SharePoint libraries while preserving Created, Modified, Author, and Editor metadata is to use the SharePoint Migration API via the PnP Framework Migration module or SharePoint Migration Tool (SPMT). Unlike PnP.PowerShell, which uses standard upload methods that can't set system-managed fields, the migration API is designed specifically for high-fidelity transfers and supports metadata preservation at scale. This approach is officially supported by Microsoft, reliable for large volumes, and avoids the limitations and manual overhead of Power Automate.

    ------------------------------------
    Don't forget to mark as solution if my answer suits you

  • obiobis's avatar
    obiobis
    Brass Contributor

    The Move-PnPFile command automatically preserves metadata such as creator and time during migration.

    • catereilly's avatar
      catereilly
      Copper Contributor

      thanks - this is the direction I needed to get it sorted

  • PankajBadoni's avatar
    PankajBadoni
    Iron Contributor


    Yes, it is possible to update the Created and Modified dates using PnP PowerShell.

    In your scenario, you can first retrieve the original metadata (including Created and Modified dates) either by downloading it along with the file or directly querying it from the source SharePoint library. After uploading the file to the target location, you'll receive a new item ID. Using this ID, you can then update the Created and Modified dates via PnP PowerShell.

    Set-PnPListItem -List <ListName> -Identity <ID> -Values @{
        Created = "7/30/2025"
        Modified = "7/29/2025"
    }

    While this approach requires an investment in scripting and setup, there are also SharePoint and  commercial migration tools available that can simplify the process and may be worth considering depending on your needs.

Resources