问题描述
Get-EventLog -LogName Application | Where-Object Source -Match "my application" | export-csv "$FileDate.csv"
当我打开 CSV 文件时,它看起来也不是我想要的样子。它显示
EventID,"MachineName","Data","Index","Category","CategoryNumber","EntryType","Message","Source","ReplacementStrings","InstanceId","TimeGenerated","时间写入”、“用户名”、“站点”、“容器” 0,"DESKTOP-ID94AN3","System.Byte[]","21425","(0)","0","错误","完成 执行项目 'Testproject' 执行包 'Failure' 执行 失败开始时间:21/12/2020 19:47:52 结束时间:21/12/2020 19:47:56 在服务器上:DESKTOP-ID94AN3 -日志消息
文本到列之后:
在不应该出现的列中包含信息。它似乎结合了事件查看器中的 2 个窗口。带有错误的“上”窗口和带有详细信息的“下”窗口。我想要的只是上面的窗口。
如果我在 Windows Powershell ISE 中运行此代码:
Get-EventLog -LogName Application | Where-Object Source -Match "Myapplication"
它看起来像我想要的样子(在使用文本到列之后):
Index Time EntryType Source InstanceID Message
----- ---- --------- ------ ---------- -------
21425 Dec 21 19:47 Error Myapplication LogEn... 0 Message 1
21424 Dec 21 19:47 information Myapplicationr LogEn... 0 Message 2
如何让我的 CSV 导出看起来也像这样?