Change the author of a SharePoint page with PowerShell

11 juni 2020

Recently a client asked us who receives a notification when a comment is posted on a modern SharePoint page. We explained that this is the original author of the SharePoint page. This person receives the notification through e-mail. Unfortunately, this was a problem for our client.

New client

We just finished a brand-new shiny intranet for our client. We provided the design and implementation of the SharePoint intranet and helped them to collaborate in a better and more modern way by using Microsoft 365. The client was responsible for the creation of the content that would be displayed in the SharePoint intranet. In this implementation, one employee of our client created many SharePoint pages which provided all kinds of information in the intranet. This was very helpful, but unfortunately the employee left the company shortly after. This left their new intranet with lots of pages where the page author was no longer within the company. Normally this is not a problem because other SharePoint admins have the possibility to modify those pages if necessary. But there was one problem that could not be solved with the standard tools provided in SharePoint. Changing the author of a SharePoint page, hence changing the person that gets notified when comments are placed.

The request

The client wanted to be able to change the person who gets the notifications. This was especially important because the intranet would soon be launched and used throughout the company. If comments were posted somebody needed to be informed. The client asked us to provide them with the possibility to change the field “Author” for their SharePoint pages. So that they could be sure somebody within the company was notified when comments were placed.

Our solution

Because this is not possible through the UI of SharePoint, we quickly turned to PowerShell to help us achieve this goal. The following script helped our client to change the author of a SharePoint page. By changing the author, you change person who receives the notification when comments are placed on a page.

Before using the script please make sure that you have updated PowerShell to the latest version.


To use the script, you will need to fill the following parameters.

$SiteUrl = The site that contains the page where you want to change an author of a page.
$ListName = The list which contains the page. Generally, this is "site pages".
$ID = To get the ID of a page you will need to add a column to the “site pages” list or the list which contains your pages. Simply edit your view.


Now you can add the ID column.


$UserID = The user that will become the next author of the page.
$TimeStamp = This will adjust the time that the page was “created”. Format your time like this “2020/01/01 02:10:00 AM”

#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://yourtenant.sharepoint.com/sites/yoursite"
$ListName= "site pages"
$ID= "YourID"
$TimeStamp = "YourTimeStamp"

#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

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

#Update List item

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

Source script: https://sharepoint.stackexchange.com/questions/246694/how-to-update-createdbyauthor-field-using-powerhsell-sharepoint-csom 


Submit a comment