系统日志的PowerShell脚本问题

时间:2019-02-18 19:07:33

标签: powershell

我遇到的问题是前三行。一旦运行,日志将被拉入txt文件,但在一定数量的字符后添加“ ...”,而不是返回整行。关于如何阻止它的任何想法?

Get-EventLog -Newest 1000 -LogName "Security" | Out-File -FilePath C:\SecurityLogs.txt
Get-EventLog -Newest 1000 -LogName "System" | Out-File -FilePath C:\SystemLogs.txt
Get-EventLog -Newest 1000 -LogName "Application" | Out-File -FilePath C:\ApplicationLogs.txt
Get-Item -Path C:\Windows\Prefetch\* | Out-File -FilePath C:\prefetch.txt
Get-Process -FileVersionInfo | Out-File -FilePath C:\processes.txt

1 个答案:

答案 0 :(得分:0)

您正在将命令的预格式化文本保存到文件中。您可以执行以下操作。

Get-EventLog -Newest 1000 -LogName "Security" | select * | out-file -FilePath C:\SecurityLogs.txt

这将扩展每个属性。

此命令Get-EventLog -Newest 1000 -LogName "Security" | get-member还将显示您也有权访问以显示的所有attribute \ properties。

然后您可以运行类似的内容:

Get-EventLog -Newest 1000 -LogName "Security | Select-Object index, timewritten, message | format-list`

您可以使用format-listformat-table和其他输出命令来获得所需的结果。

您还可以执行其他方法。您希望最终结果是什么取决于您使用什么。

相关问题