【问题标题】:Powershell get-eventlog message column is too shortPowershell get-eventlog 消息列太短
【发布时间】:2009-09-18 09:58:49
【问题描述】:

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

索引时间类型源EventID消息
----- ---- ---- ------ -------- --------
18 年 9 月 2 日 12:50 信息 yadddayadda 0 类:Controllers.BasketController...
2018 年 9 月 1 日 12:50 信息 yadddayadda 0 类:Controllers.BasketController...

是否可以看到完整的消息?

【问题讨论】:

  • 属于服务器故障。
  • 两者都为我工作:.... | Format-Table -AutoSize -Wrap & ..... | select -ExpandProperty message(在查询末尾放置一个或另一个)

标签: powershell event-log


【解决方案1】:

您会看到该类型的默认表格格式(这将在其中一个安装(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" 正是我需要的。非常感谢。 :)
  • 我试图将“format-table -auto -wrap”添加到查询末尾,但出现错误(“无法将值格式表转换为 System.Int64 类型”)。通过将查询修改为如下所示来解决此问题: Get-EventLog -LogName Application -After (get-date).addDays(-7) -Message "custom message" |格式表 -wrap > file.txt
【解决方案2】:

如果你只想提取错误信息,除了上面提出的方法,你可以使用-ExpandProperty如下:

Get-EventLog -LogName Application -Newest 10 -EntryType Warning | select -ExpandProperty message

这将提取整个错误消息。

【讨论】:

    【解决方案3】:

    管道到格式列表。

    【讨论】:

      【解决方案4】:
      Just Open the Command Prompt window and click on the leftmost top corner.
      >Select Properties
      >Go to Layouts tab
      >Increase the width and height of the Screen Buffer size and Window size.
      

      这行得通。

      【讨论】:

      • 这不是正确答案,因为您将达到新屏幕尺寸的限制。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-04-06
      • 1970-01-01
      • 2014-05-20
      • 2017-03-12
      • 2020-03-25
      相关资源
      最近更新 更多