PowerShellコード可読性低すぎワロタwww時代はC#ですわ

Add-Type -TypeDefinition @"
using System.IO;
using System.Text.RegularExpressions;
public class Hoge {
private static readonly Regex r = new Regex(@"[^\n]*てすと$", RegexOptions.Compiled | RegexOptions.Singleline | RegexOptions.CultureInvariant);
public static void ReplaceLastTest(FileInfo file) {
string s = File.ReadAllText(file.FullName);
s = r.Replace(s.TrimEnd(), string.Empty) + "てすと";
File.WriteAllText(file.FullName, s);
}
}
"@

[Hoge]::ReplaceLastTest((Get-ChildItem ./test.txt))