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!