I need to update the CreatedBy(Author) field using CSOM Powershell Sharepoint Online.

I tried:

$user=$ctx.Web.EnsureUser("[email protected]")






But this is not updating .I have given mailid to EnsureUser() method because I have only mailId of the user.

can anyone help me with correct solution.

2 Answers 2


Try the below PowerShell Script to can Update Created By / Modified By Fields values using PowerShell CSOM in SharePoint Online

#Load SharePoint CSOM Assemblies
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll"
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"

##Variables for Processing
$SiteUrl = "https://crescent.sharepoint.com/sites/sales/"
$ListName= "Projects"
$UserID="[email protected]"
$TimeStamp = "2015/12/01 02:10:00 AM"

#Get Credentials to connect
$Cred = Get-Credential
$Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.Username, $Cred.Password)

#Setup the context
$Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteUrl)
$Ctx.Credentials = $Credentials

#Get the User
$User = $Ctx.Web.EnsureUser($UserID)

#Get the list Item
$ListItem = $List.GetItemById($ID)

#Update Created by & Modified By
$ListItem["Author"] = $User
$ListItem['Editor'] = $User

#Set Created on & Modified on Time values
$ListItem["Created"] =  $TimeStamp
$ListItem["Modified"] = $TimeStamp

#Update List item

Write-host "Metadata values updated Successfully!" -f Green

Credit to: SharePoint Online: Update Created By / Modified By, Created At / Modified At Field values using PowerShell CSOM

  • This is working fine for custom list,but I am updating for a Page in Page library.I dont know why it is not getting updated for a page.But showing modified few seconds ago.
    – Swetha
    Aug 8, 2018 at 5:27

It works for me (on SP2016 OnPrem) only when I change two fields at the same time


just try it out, maybe it works also for you

  • this is working for me for custom lists not for Page lib and Document library.I am working for SPOnline site.
    – Swetha
    Aug 8, 2018 at 12:41
  • This is working for me for both of types. It seems like SPO is (once again) slightly different than OnPrem...
    – MM8903
    Aug 8, 2018 at 12:48

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.