PnP Powershell - Setting "modified by" on documents in library

Copper Contributor

Hi,

I have a document library where I want to mass change the "modified by" of the documents in it. I've tried the following on a single document:

 

 

$List = "My document library"
$ID = "2"
Set-PnPListItem -List $List -Identity $ID -Values @{"Editor"="email address removed for privacy reasons"}

 

 

 

The response looks ok (doesn't throw any errors):

 

 

 

Id    Title                                              GUID
--    -----                                              ----
2                                                        xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx

 

 

 

But, when I look at the document in the library, it has indeed changed, but it has the wrong user as Editor - It's the Powershell user that issued the command, rather than the user that I specified in Set-PnPListItem. What am I doing wrong?

 

(I wondered if I used the wrong field, but what I can see, "Editor" is the one to use)

 

EDIT: I also tried the field "Modified_x0020_By", but with the same result.

1 Reply

@JimGr Yes, Editor is the correct internal name of Modified by column in SharePoint.

 

Also, you have to use the -UpdateType parameter with the Set-PnPListItem cmdlet.

 

Check below links for more information about what value to use for this parameter:

  1. Set-PnPListItem 
  2. How to change the value of a column "Modified By" of a SharePoint List with PowerShell?  

Please click Mark as Best Response & Like if my post helped you to solve your issue. This will help others to find the correct solution easily. It also closes the item. If the post was useful in other ways, please consider giving it Like.

For SharePoint/Power Platform blogs, visit: Ganesh Sanap Blogs