Minggu, 13 Februari 2011

Powershell - Get-EventLog Message Truncated

In efforts to automate some log monitoring/searching I turned to the Get-EventLog cmdlet. After getting it up and running I always have problems with the Message being truncated to a single line ended with an ellipsis. To get around this I Googled up this post:
http://www.experts-exchange.com/Programming/Languages/Scripting/Powershell/Q_25029432.html
Although the main emphasis of the post was answered by a response emphasizing something else, I did find this nugget by Learnctx:
get-EventLog application -newest 2000 | where {$_.entryType -match "Error"} | where{$_.source -match "vmauthd"} | where{$_.timewritten -match $tdate} | format-table timewritten, message -wrap -autosize | Out-File -filepath c:\test.txt
From within this reply I got the command:
format-table timewritten, message -wrap -autosize
Applying this to my own command I then came up with this approach to see a specific log entry in a readable format:
$log = Get-EventLog -LogName Application
$log[0] | Format-Table -AutoSize -Wrap
To see all fields of the message try this:
$log[0] | Format-Table -AutoSize -Wrap
If you just select the Message field, it is automatically formatted:
$log[0].Message

0 komentar:

Posting Komentar

 
Powered by Blogger