Sometimes it is necessary to modify the 'Created By' field value for each list item and set it to the respective user's login ID. In my case it was required to Update "Created By" field value of Comments List of Blog Site. There was 1200+ comments in the list to modify.
The example simply replaced the created by field with user X to user Y. Apparently you also need to specify the user ID during replace Created by or Modified by.
$web=get-SPWeb "You Web URL"
You can get the user ID of the user using the "
EnsureUser()" method of "web" in PowerShell command.
The code "
$item["Author"] = $replacedUser " is used to updated the "Created By" column.
if you want to update the "Modified By" column, you have to add the code below:
"$item["Editor"] = $replacedUser "
foreach($item in $list.Items)
$item["Author"] = $replacedUser
$item["Editor"] = $replacedUser
Don't forget to use
$item.update() at the end, because otherwise your new value won't get displayed.