Powershell get-eventlog message column is too short
Asked Answered
M

4

27

When using powershell to retrieve info about events Message column gets trimmed and is too short:

Index Time Type Source EventID Message
----- ---- ---- ------ ------- -------
2 Sep 18 12:50 Info yaddayadda 0 Class: Controllers.BasketController...
1 Sep 18 12:50 Info yaddayadda 0 Class: Controllers.BasketController...

Is it possible to see full message?

Maccaboy answered 18/9, 2009 at 9:58 Comment(2)
Belongs on Server Fault.Vignola
both worked for me: .... | Format-Table -AutoSize -Wrap & ..... | select -ExpandProperty message (put one or the other at the end of your query)Gaultheria
V
30

You are seeing the default table format for the type (this will be define in one of the install (x.format.ps1.xml files).

You can:

  • Use a wider console window, the final column fills the available space.
  • Add format-table -wrap to the end of pipeline and PSH will wrap the text of the final column.
  • Add format-table -auto to the end of the pipeline and PSH will adjust all the columns to fit (but needs to see all the data first, so you will not get incremental results).
  • Use both -auto and -wrap.
  • Specify the table format you want. Specify a list of properties to display. Or a list of hashes defining the columns (in this case each can have its own label, alignment, width and expression). See help format-table -full for details.
Vignola answered 18/9, 2009 at 10:15 Comment(2)
"get-eventlog -logname Foo format-table -auto -wrap" did exactly what i needed. Thanks a lot. :)Maccaboy
I was trying to add "format-table -auto -wrap" to the end of the query and was getting an error ("Cannot convert value format-table to type System.Int64"). Worked around that by modifying the query to look like this: Get-EventLog -LogName Application -After (get-date).addDays(-7) -Message "custom message" | format-table -wrap > file.txtGardener
M
15

In addition to the methods proposed above you can use the -ExpandProperty as follows if you only want to extract the error message:

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

This will extract the entire error message.

Millda answered 5/5, 2015 at 19:37 Comment(0)
S
6

Pipe to Format-List.

Spoilfive answered 18/9, 2009 at 13:4 Comment(0)
C
0
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.

This works.

Ceiling answered 13/7, 2017 at 12:21 Comment(1)
This is not the right answer as you will get to the limit of the new screen size.Landside

© 2022 - 2024 — McMap. All rights reserved.