SharePoint Online: How to Change the Author in Modern Page?

Requirement: Set Author in the header section of the modern SharePoint Online page.

How to change the author in SharePoint Online Modern Pages?

Setting the author field in SharePoint Online modern pages is quite straightforward. Simply click on the author field and start typing the user name. If there is an existing author set, You can remove it by clicking on the “x” symbol and then entering the new author.

sharepoint online change page author

PowerShell to Set Author in Modern SharePoint Online Pages

How about changing the author using PowerShell? Here is the PowerShell to set the Author in the Page Header area.

#Parameters
$SiteURL = "https://crescent.sharepoint.com/sites/Marketing"
$PageName = "Home.aspx"
$AuthorEmail = "[email protected]"

Try {
    #Connect to PnP Online
    Connect-PnPOnline $SiteURL -Interactive

    #Get the Page
    $Page = Get-PnPPage -Identity $PageName

    #Resolve the Author User
    $Author = Get-PnPUser | Where-Object Email -eq $AuthorEmail
    If($Author -eq $null) {        
        $Author = New-PnPUser -LoginName $AuthorEmail
    }

    #Set the Authors and AuthorByLine properties of the PageHeader - in JSON format
    $Page.PageHeader.Authors = "[{`"id`":`"$($Author.LoginName)`"}]"
    $Page.PageHeader.AuthorByLine = "[`"$($Author.Email)`"]"

    #Save the changes and publish the page
    $Page.Save() | Out-Null
    $Page.Publish()
}
Catch {
    write-host -f Red "Error:" $_.Exception.Message
}

Salaudeen Rajack

Salaudeen Rajack is a SharePoint Architect with Two decades of SharePoint Experience. He loves sharing his knowledge and experiences with the SharePoint community, through his real-world articles!

One thought on “SharePoint Online: How to Change the Author in Modern Page?

  • November 8, 2021 at 2:30 PM

    Can the updated AuthorByLine user gets, SP notification emails related to page comments and likes?

    Reply

Leave a Reply