PowerShell テキストファイル操作
ファイルの空行を削除して標準出力
$file = Get-Content hoge.txt $file | Out-String -Stream | ?{$_ -ne ""}
可変リストに行を追加
using namespace System.Collections.Generic $myList = [List[String]]@() myList.Add("hoge")
foreachでループ
$newfile = foreach ($line in $file) { if ($line.StartsWith("hoge")) { $str + "," + $line } else { $str = $line } }