Text truncated in message field powershell command

Posted on 2010-01-07
Last Modified: 2012-05-08

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!
Question by:changjia
    LVL 16

    Expert Comment

    Try using format-table with the wrap switch instead of format-wide.
    LVL 16

    Expert Comment

    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

    LVL 70

    Expert Comment

    by:Chris Dent

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


    Author Comment

    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?

    LVL 16

    Accepted Solution

    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


    Featured Post

    Live: Real-Time Solutions, Start Here

    Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

    Join & Write a Comment

    Suggested Solutions

    A commonly asked question on the site recently has been regarding how do I share the GAL between different forests? I want a list of Contacts representing all the users in a remote domain, How do i get them? It's a problem I was posed with a litt…
    This article will show, step by step, how to integrate R code into a R Sweave document
    Learn the basics of strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    24 Experts available now in Live!

    Get 1:1 Help Now