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 relatively straightforward. Here are the steps to add or change the page author:
- Simply click on the author field in the title area and start typing the user name. If there is an existing author set, You can remove it by clicking on the “x” symbol and entering the new Author.
- Enter the name or email of the author in the author box. You’ll get a list of available users in the drop-down.
- Pick the desired author and publish the page.
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 = "mark@crescent.com"
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
}
Can we get an export of all published pages and their authors? We still have pages that have authors who have the left organisation. Need an easy way to identify these…
If I want to remove the Author Profile completely from the site page and do this for multiple pages, how will I modify this script ?
Here is how to get all pages:
Can the updated AuthorByLine user gets, SP notification emails related to page comments and likes?