* ConvertTo-Csv [#aa60abff]
*** TYPEの削除 -NoTypeInformationオプション[#m7eb79a6]
PS> dir *.txt | select FullName, FileSize, LastWriteTime | ConvertTo-Csv
#TYPE Selected.System.IO.FileInfo <= *** この行が不要な場合 ***
#TYPE Selected.System.IO.FileInfo <= *** この行が不要な場合 ***
"FullName","FileSize","LastWriteTime"
"C:\tmp\1.txt"," 786 B ","2018/05/15 3:40:31"
"C:\tmp\2.txt"," 786 B ","2018/05/15 3:40:24"
↓
PS> dir *.txt | select FullName, FileSize, LastWriteTime | ConvertTo-Csv -NoTypeInformation
"FullName","FileSize","LastWriteTime"
"C:\tmp\1.txt"," 786 B ","2018/05/15 3:40:31"
"C:\tmp\2.txt"," 786 B ","2018/05/15 3:40:24"
*** デリミタの指定 -Delimiter [#uae67c4f]
dir * | select FullName, FileSize, LastWriteTime | ConvertTo-Csv -Delimiter "`t"
ここではタブ区切りを指定。
*** 最初の行のヘッダーなど、邪魔な行があるのを消す select -Skip [#x37b6c0d]
PS> dir *.txt | select FullName, FileSize, LastWriteTime | ConvertTo-Csv -NoTypeInformation
"FullName","FileSize","LastWriteTime" <= *** この行が邪魔 ***
"C:\tmp\1.txt"," 786 B ","2018/05/15 3:40:31"
"C:\tmp\2.txt"," 786 B ","2018/05/15 3:40:24"
↓
PS> dir *.txt | select FullName, FileSize, LastWriteTime | ConvertTo-Csv -NoTypeInformation | select -Skip 1
"C:\tmp\1.txt"," 786 B ","2018/05/15 3:40:31"
"C:\tmp\2.txt"," 786 B ","2018/05/15 3:40:24"
** 参考 [#v9e486f8]
https://msdn.microsoft.com/en-us/powershell/reference/5.1/microsoft.powershell.utility/convertto-csv