有没有办法将数据导出为 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?