Hi @Nigel Foot ,
Per my test, I use the following script successfully set the Creator and Author of the last 24 hours update files which Author's email address equals aaa@xxx.onmicrosoft.com
#Config Parameters
$SiteURL = "https://xxx.sharepoint.com/sites/xiexin"
$LibraryName = "Document Lib"
$Title = "filename.aspx"
$EmailAddress = "aaa@xxx.onmicrosoft.com"
$CreatedBy = "bbb@xxx.onmicrosoft.com"
Connect-PnPOnline -Url $SiteURL -Interactive
$List = Get-PnPList -Identity $LibraryName
$ListItems = Get-PnPListItem -List $LibraryName
Foreach ($Item in $ListItems){
$Name = $Item["FileLeafRef"]
$Modified = $Item["Modified"]
$nowtime = get-date
$ModifiedTime = ($nowtime - $Modified).totalhours
$CreatorEmail = $Item["Author"].Email
If(($ModifiedTime -le 24) -and ($EmailAddress -eq $CreatorEmail)){
Set-PnPListItem -List $LibraryName -Identity $Item.Id -Values @{"Title" = $Title; "Author" = $CreatedBy; "Editor" = $CreatedBy}
}
}
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.