title: Powershell: Autosize and Specific Column Width
body: <p>Based on this SO question <a href="https://stackoverflow.com/questions/22622782/powershell-output-collection-of-objects">Powershell: Output collection of objects</a>, I am able to wrap a collection of strings in multiple lines in one column. However, when I try to output the collection to table-view, the autosize would not allow me to specify specific column width.</p>
  
  <p>For example:</p>
  
  <pre><code>id     name     items                                                          others
  ---    ----     -----                                                          -----
  01     a        ("The first item", "The second item", "The third item", "...")  ...
  02     ....
  </code></pre>
  
  <p>Here is my output:</p>
  
  <pre><code>$colObjs | Select-object id, name, items, others`
     @{Expression={($_.items -join "`n")};Label="Items"} | `
     Format-table -autosize -wrap
  </code></pre>
  
  <p>Then the <code>items</code> column would be the whole length of strings in its array:</p>
  
  <pre><code>id     name     items                                                          others
  ---    ----     -----                                                          -----
  01     a        "The first item"                                               ...
                  "The second item"                                              ....
                  "The third item"
                  ...
  02     ....
  </code></pre>
  
  <p>I tried to use the following codes, still the width of <code>items</code> column not as expected:</p>
  
  <pre><code>$colObjs | Select-object id, name, items, others `
     @{Expression={($_.items -join "`n")};Label="Items"} | `
     Format-table id, name, `
       @{expression={$_.items}; label="items"; width=18}, others `
     -autosize -wrap
  </code></pre>
  
  <p>Specially, if the <code>items</code> have a long list of strings, the table view looks very ugly, too much spaces in column <code>items</code>.</p>
  
  <p>This is the format what I want:</p>
  
  <pre><code>id     name     items              others
  ---    ----     -----              -----
  01     a        "The first item"   ...
                  "The second item"  ....
                  "The third item"
                  ...
  02     ....
  </code></pre>
  
  <p>Is this true that -autosize would make width having no effect? How can I specify the width of <code>items</code> and leave other columns as auto-sized?</p>