つうかこれでええやんwwww
誰だよC#とか言ったアホwwwww

function Update-LastTest ([IO.FileInfo]$file) {
$s = Get-Content $file | Out-String
$s = ($s.TrimEnd() -replace '[^\n]*てすと$', '') + 'てすと'
$s | Out-File $file
}

Update-LastTest (Get-ChildItem ./test.txt)