There's probably a bunch of different ways to do this, but here's a snippet from some C# code that I wrote a while back converted to PowerShell. Hope it's along the lines of what you're looking for:
Start-SPAssignment -Global
$web = Get-SPWeb "http://sharepointdev:90"
$list = $web.Lists.TryGetList("Site Pages")
foreach ($file in $list.RootFolder.Files)
{
if ($list.ForceCheckout) { $file.CheckOut() }
$html = [System.Text.Encoding]::ASCII.GetString($file.OpenBinary())
$html = $html.Replace("p", "P")
$file.SaveBinary([System.Text.Encoding]::ASCII.GetBytes($html))
if ($list.ForceCheckout) { $file.CheckIn() }
}
Stop-SPAssignment -Global