I am moving files from a file share to SharePoint Online. The files are in different folders, one for each release, on the file share. The idea is that these releases should be visible in the version history in SharePoint Online instead. So I am using Add-PnPFile to add each file release to the a document library and at the same time I am adding metadata extracted from the folder structure and the files.

In the Version history in SPO the columns Modified and Modified By are the most visible elements, so these properties need to be set to the properties that I am specifying to Add-PnPFile. But the issue is that the script is totally ignoring the values that I am specifying. Even if I hard-code a date, I get today´s date instead. And for Modified By I get my name instead of the one I specify.

The date format that I get from the file system is like 2019-12-09 09:15:14. That is what I get from the file system using $File.CreationTime and $File.LastWriteTime. But I have tried hard-coding the US version as well.

The format I specify for Modified By is an email address and it does not work. I have specified the same format for Created By and it works.

I have had issues before with these properties and then I used Set-PnPListItem as a work-around. But since that creates an extra item in the version history, I cannot use that work-around this time.

I have run the command Install-Module -Name PnP.PowerShell -RequiredVersion 1.5.0 -Scope CurrentUser , so hopefully that is the version I am using.

This is how my Add-PnPFile looks like: Add-PnPFile -Path $File.Fullname -Folder $SiteRelativePath -Values @{"Title" = $File.Name; "Created"=$createdDate; "Modified"=$modifiedDate; "Document_x0020_Date"=$createdDate; "Editor"=$email; "Author"=$email; "Language"=$Language; "Revision"=$Revision; "Release"=$Release; "Product"=$Product; "DocumentKind"=$DocumentKind } -Checkout

Please help!

1 Answer 1


Per my test, I got the same result as yours when installing the PnP.PowerShell version 1.5.0. And installing the latest version(nightly) will solve this issue.

Run following command to uninstall old version:

Uninstall-Module -Name "PnP.PowerShell"

Finally run following command to install latest version:

Install-Module -Name PnP.PowerShell -AllowPrerelease
  • If I change Require Checkout to false and remove the -Checkout switch from the command, it works after I have upgraded. But I can enable check out after the migration so I am fine with that. Thank you very much!
    – Gunilla
    Commented May 31, 2021 at 15:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.