Setting AuthorByline using PnP PowerShell
Recently I had to look into setting the AuthorByline of a modern page using PowerShell. As some suggestions (translated to PowerShell) found by searching
on the internet didn't seem to work, I started looking into the possibilities. I came up with the following PowerShell, that uses PnP PowerShell to
get the user added and visible in the modern page.
I used the following PowerShell commands to set the AuthorByline:
$page = Get-PnPClientSidePage -Identity "Test-page.aspx"
$user = New-PnPUser -LoginName "test.user@mypersonaltenant.onmicrosoft.com"
$author = @(@{ "id" = $user.LoginName })
$page.PageHeader.Authors = ConvertTo-Json $author
$page.Save()
I hope this is helpful to you, as this was not that straight forward.