Use the SDL Web Core Service to edit a component
$ErrorActionPreference = "Stop"
# get a Core Service client
Import-Module Tridion-CoreService -Verbose:$false
Set-TridionCoreServiceSettings -Version "Web-8.1"
Set-TridionCoreServiceSettings -HostName localhost -ConnectionType Default
$client = Get-TridionCoreServiceClient
# get the component to edit
$componentId = "tcm:25-4220"
$component = Get-TridionItem $componentId
$component.Id
$component.Content
# example 1: get an older version of the component and restore the component content
$oldComponentId = $component.Id + "-v" + ($component.VersionInfo.LastVersion -1)
$oldComponent = Get-TridionItem $oldComponentId
$oldComponent.Id
$oldComponent.Content
$component.Content = $oldComponent.Content
# example 2: replace some value
$component.Content = $component.Content.Replace("<linkText>a</linkText>", "<linkText>b</linkText>")
$component.Content
$readBackOptions = New-Object Tridion.ContentManager.CoreService.Client.ReadOptions
pause
$client.Update($component, $readBackOptions)