Text truncated in message field powershell command

Hi,

I use powershell to pull a event from event log. the command ran successfully, but the message field got truncated. I want to view the whole message instead of just the first line, how to do this?

The powershell script I use is:
get-EventLog application -newest 2000 | where {$_.entryType -match "Error"} | where{$_.source -match "vmauthd"} | where{$_.timewritten -match $tdate} |format-wide -column 2 timewritten, message | Out-File -filepath c:\test.txt

The result looks like this


TimeWritten                          message                                                                              
7:29:25 PM  Cannot connect to VMX: E:\Virtual Machines\Virtual Machine\Virtual Machine.vmx...        


Thanks in advance for you help!
changjiaAsked:
Who is Participating?
 
LearnctxConnect With a Mentor EngineerCommented:
If you need to spread a command across multiple lines, use the tick `
For example.
Get-Process | `
  Sort Name | `
  Select Name

Open in new window

0
 
LearnctxEngineerCommented:
Try using format-table with the wrap switch instead of format-wide.
0
 
LearnctxEngineerCommented:
I suppose some code would have been handy :)

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

Open in new window

0
 
Chris DentPowerShell DeveloperCommented:

Or export to CSV, then you don't have to worry about trying to make the format-* cmdlets display things.

Chris
0
 
changjiaAuthor Commented:
Awesome. After I paste the long command into the powershell window, it errored out because the command is too long and it doesn't fit on one line.. How to resolve this?

Thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.