Smarter Business Solutions Logo
SMARTER Business Solutions
Office365 SharePoint Blog

Restore ShareGate Created and Modified Timestamps Fast

Learn how to restore Created and Modified timestamps on a local file share after a ShareGate migration by reading the export CSV with a PowerShell script.

5 Min Read

Every ShareGate migration to a local file share seems to end with the same surprise: all copied files suddenly show the day of the migration as their Created and Modified timestamps. That breaks auditing trails and confuses users. Fortunately, the ShareGate export already ships the real metadata, and a compact PowerShell script can write it back in minutes.

Why ShareGate overwrites the timestamps

When you export libraries or OneDrive content, ShareGate stores every relevant property in a CSV file. Copying the files to NTFS with Explorer or RoboCopy, however, creates new timestamps by design. The CSV therefore becomes the single source of truth for the original Created and Modified values, and PowerShell can reapply them exactly where they belong.

Export the CSV from ShareGate

ShareGate CSV with created and modified timestamps

The CSV lists each destination path plus the original dates. PowerShell can iterate through the rows, map them to the migrated files, and restore the metadata one by one.

PowerShell script for Created and Modified attributes

Prepare the environment

Save the ShareGate CSV on the file server and note the root folder that contains the migrated data set. Substitute both paths in the script before running it so the import can find the file and the loop can resolve the NTFS paths.

Run the script

$csv = Import-Csv "E:\Export\ShareGateAttributes.csv" -Delimiter ';'
$RootFolder = "E:\ShareGate Export\"

# Process each line from the CSV
$csv | ForEach-Object {
    # Normalize the ShareGate destination path for NTFS
    $filePath = $RootFolder + $_.DestinationPath.Replace("/", "\")

    try {
        (Get-Item $filePath).CreationTime = Get-Date $_.Created
        (Get-Item $filePath).LastWriteTime = Get-Date $_.Modified
    }
    catch {
        Write-Error $_ -BackgroundColor Red
    }
}

The loop reads every row, converts the ShareGate destination to a Windows path, and assigns the original timestamps back to the target file.

How the script works

  1. Import-Csv loads the file and exposes each column as a property.
  2. ForEach-Object retrieves the local item via Get-Item.
  3. The CreationTime and LastWriteTime members receive the Created and Modified values.
  4. Any missing files trigger an error so you can rerun the migration for those paths.

With just a few lines of PowerShell you can keep your compliance trail intact and deliver migrated data that still mirrors the real editing history.

Tags

#File share #Migration #Microsoft 365 #PowerShell #SharePoint

Ready to transform your SharePoint?

Let our experts help you implement the solutions discussed in this article.