Export-Csvコマンド
PowerShellのExport-Csvコマンドについてです。
以下のコマンドで、Cドライブにある情報をCSV形式に出力しました。
PS C:\> Get-ChildItem |Export-Csv test01.csv -Encoding default
そして、C:\script-testフォルダ内の情報をCSV形式で出力しようと
Export-Csvコマンドを実行し、出来上がったCSVファイルを見てみると
何かがおかしい状態となっております。。CSV出力できていないのでしょうか?
PS C:\script-test> Get-ChildItem | Export-Csv test01.csv -Encoding default
↓↓出来上がったCSVファイルの中身↓↓
#TYPE System.IO.FileInfo
"PSPath","PSParentPath","PSChildName","PSDrive","PSProvider","PSIsContainer","VersionInfo","BaseName","Mode","Name","Length","DirectoryName","Directory","IsReadOnly","Exists","FullName","Extension","CreationTime","CreationTimeUtc","LastAccessTime","LastAccessTimeUtc","LastWriteTime","LastWriteTimeUtc","Attributes"
"Microsoft.PowerShell.Core\FileSystem::C:\script-test\addres.txt","Microsoft.PowerShell.Core\FileSystem::C:\script-test","addres.txt","C","Microsoft.PowerShell.Core\FileSystem","False","File: C:\script-test\addres.txt
InternalName:
OriginalFilename:
FileVersion:
FileDescription:
Product:
ProductVersion:
Debug: False
Patched: False
PreRelease: False
PrivateBuild: False
SpecialBuild: False
Language:
","addres","-a---","addres.txt","153","C:\script-test","C:\script-test","False","True","C:\script-test\addres.txt",".txt","2014/09/04 22:29:00","2014/09/04 13:29:00","2014/09/04 22:29:00","2014/09/04 13:29:00","2014/09/04 23:03:30","2014/09/04 14:03:30","Archive"
"Microsoft.PowerShell.Core\FileSystem::C:\script-test\date.ps1","Microsoft.PowerShell.Core\FileSystem::C:\script-test","date.ps1","C","Microsoft.PowerShell.Core\FileSystem","False","File: C:\script-test\date.ps1
InternalName:
OriginalFilename:
FileVersion:
FileDescription:
Product:
ProductVersion:
Debug: False
Patched: False
PreRelease: False
PrivateBuild: False
SpecialBuild: False
Language:
","date","-a---","date.ps1","18","C:\script-test","C:\script-test","False","True","C:\script-test\date.ps1",".ps1","2014/09/02 19:22:53","2014/09/02 10:22:53","2014/09/02 19:22:53","2014/09/02 10:22:53","2014/09/02 19:22:53","2014/09/02 10:22:53","Archive"
"Microsoft.PowerShell.Core\FileSystem::C:\script-test\sumtest.ps1","Microsoft.PowerShell.Core\FileSystem::C:\script-test","sumtest.ps1","C","Microsoft.PowerShell.Core\FileSystem","False","File: C:\script-test\sumtest.ps1
InternalName:
OriginalFilename:
FileVersion:
FileDescription:
Product:
ProductVersion:
Debug: False
Patched: False
PreRelease: False
PrivateBuild: False
SpecialBuild: False
Language:
","sumtest","-a---","sumtest.ps1","238","C:\script-test","C:\script-test","False","True","C:\script-test\sumtest.ps1",".ps1","2014/09/02 19:30:15","2014/09/02 10:30:15","2014/09/02 19:30:15","2014/09/02 10:30:15","2014/09/02 19:30:15","2014/09/02 10:30:15","Archive"
"Microsoft.PowerShell.Core\FileSystem::C:\script-test\test1.csv","Microsoft.PowerShell.Core\FileSystem::C:\script-test","test1.csv","C","Microsoft.PowerShell.Core\FileSystem","False","File: C:\script-test\test1.csv
InternalName:
OriginalFilename:
FileVersion:
FileDescription:
Product:
ProductVersion:
Debug: False
Patched: False
PreRelease: False
PrivateBuild: False
SpecialBuild: False
Language:
","test1","-a---","test1.csv","2619","C:\script-test","C:\script-test","False","True","C:\script-test\test1.csv",".csv","2014/09/04 23:15:30","2014/09/04 14:15:30","2014/09/04 23:15:30","2014/09/04 14:15:30","2014/09/04 23:15:30","2014/09/04 14:15:30","Archive"
"Microsoft.PowerShell.Core\FileSystem::C:\script-test\test1.ps1","Microsoft.PowerShell.Core\FileSystem::C:\script-test","test1.ps1","C","Microsoft.PowerShell.Core\FileSystem","False","File: C:\script-test\test1.ps1
InternalName:
OriginalFilename:
FileVersion:
FileDescription:
Product:
ProductVersion:
お礼
早速の回答ありがとうございます! "abc\ndef" で読み込ませたところ、両方とも abc\ndef でした。 でも、"\""を読み込ませたところ 有効→" 無効→パースできなくてエラー となりました。 \"は効いているみたいです。 とても助かりました。 ありがとうございました!