I wanted to set specific column size. Below is the image-

Here I have set the width to be 150 & the command is-
Get-WinEvent -FilterHashtable @{ LogName = "application"; StartTime = "10/30/2014 12:00:01 AM"; EndTime = "10/30/2014 11:59:59 PM" } | Select providername, timecreated, id, leveldisplayname, message | Format-Table | Out-String -Width 150
As you can see the Messages are getting trimmed and TimeCreated column has lot of extra width. How can I set custom width for each column so that I can reduce the size for TimeCreated column and increase it for Message column.
Use the
-wrapparameter ofFormat-Tableto disable trimming like so:to remove unneeded column spacing use the
-Autosizeparameter. Note that using-Autosizewithout-wrapwill still shorten the last selected field if it's content is too long.More info on Output Formatting using
Format-Table:Technet