有没有办法将数据导出为CSV并同时在屏幕上查看输出? 下面的代码产生我需要的东西,但是如果我使用“tee”而不是Export-CSV,数据的存储方式与我在屏幕上看到的方式相同(正如我所期望的那样)
代码:
Get-ChildItem \\server\share-recurse -Filter "*.pst" | Where {$_.Length -gt 0} |
Select-Object Directory, Name, Length, CreationTime, LastWriteTime | Export-Csv "C:\CSVs\mynew.csv"
产地:
#TYPE Selected.System.IO.FileInfo
"Directory","Name","Length","CreationTime","LastAccessTime","LastWriteTime"
\\server\share\nightly.188\share\name","name.pst","271360","6/4/2009 2:42:21 PM","8/2/2011 12:00:32 AM","6/9/2011 8:58:50 AM"
如果我使用“tee”,屏幕和文件中的输出如下所示:
Directory : \\server\share\nightly.188\share\name
Name : name.pst
Length : 271360
CreationTime : 6/4/2009 2:42:21 PM
LastWriteTime : 6/9/2011 8:58:50 AM
有没有办法将屏幕和csv格式化为csv?
答案 0 :(得分:8)
$foo | ConvertTo-Csv | Tee-Object -File output.csv | ConvertFrom-Csv