Powershell get-eventlog消息列太短

Arn*_*psa 14 powershell event-log

使用PowerShell检索有关事件的信息时消息列被修剪并且太短:

索引时间类型源事件ID消息
----- ---- ---- ------ ------- -------
2 Sep 18 12:50 Info yaddayadda 0分类: Controllers.BasketController ...
1 Sep 18 12:50 Info yaddayadda 0类:Controllers.BasketController ...

有可能看到完整的消息吗?

Ric*_*ard 19

您将看到该类型的默认表格式(这将在其中一个安装(x.format.ps1.xml文件)中定义).

您可以:

  • 使用更宽的控制台窗口,最后一列填充可用空间.
  • 添加format-table -wrap到管道的末尾,PSH将包装最终列的文本.
  • 添加format-table -auto到管道的末尾,PSH将调整所有列以适应(但需要首先查看所有数据,因此您不会获得增量结果).
  • 使用-auto-wrap.
  • 指定所需的表格格式.指定要显示的属性列表.或者定义列的哈希列表(在这种情况下,每个列都可以有自己的标签,对齐方式,宽度和表达式).详情help format-table -full请见.

  • “get-eventlog -logname Foo format-table -auto -wrap”正是我所需要的。多谢。:) (2认同)
  • 我试图在查询结束时添加"format-table -auto -wrap"并收到错误("无法将值格式表转换为类型System.Int64").通过修改查询来解决这个问题:Get-EventLog -LogName Application -After(get-date).addDays(-7)-Message"*custom message*"| format-table -wrap> file.txt (2认同)

Yoo*_*kim 10

除了上面提出的方法之外,-ExpandProperty如果您只想提取错误消息,可以使用以下内容:

Get-EventLog -LogName Application -Newest 10 -EntryType Warning | select -ExpandProperty message
Run Code Online (Sandbox Code Playgroud)

这将提取整个错误消息.


Sha*_*evy 5

管道到格式列表。