none
Remove header from output of pipeline RRS feed

  • Question

  • I am trying to get the update time of the most recent .vhd in a folder.  I have:


    get-childitem "*.vhd" | sort-object LastWriteTime | Select-Object LastWriteTime

    My issue is I am trying to get rid of the header.  How do I do that?  I tried the option with format-table but was not able to set the result to a variable in a script.

     

    $testme = get-childitem $dstPath\$guestName\*.vhd | sort-object LastWriteTime | Format-Table -HideTableHeaders  LastWriteTime
    writehost $testme

     

    Wednesday, July 21, 2010 11:15 PM

Answers

  • This usually works, sometimes doesn't:


    get-childitem "*.vhd" | sort-object LastWriteTime | Select-Object -ExpandProperty LastWriteTime

     

    The 'ExpandProperty' parameter is supposed to be used for expanding properties that are collections, but if the property is a scalar value it will just print it out without the header. Odd, but works.

    A more direct way is:


    get-childitem "*.vhd" | sort-object LastWriteTime | ForEach-Object {$_.LastWriteTime}

    • Proposed as answer by MOW_ Wednesday, July 21, 2010 11:23 PM
    • Marked as answer by Mervyn Zhang Thursday, July 22, 2010 5:14 AM
    Wednesday, July 21, 2010 11:18 PM
  • Either of those still produce a blank output line at the beginning.
     
    I have to do this
     
       get-childitem *.vhd | sort-object LastWriteTime |
          ForEach-Object {$_.LastWriteTime} | Out-String -stream |
             select-object -skip 1

    to keep that extra beginning blank line from appearing in the output.
     

    • Marked as answer by Mervyn Zhang Friday, July 23, 2010 5:16 AM
    Thursday, July 22, 2010 1:42 AM

All replies

  • This usually works, sometimes doesn't:


    get-childitem "*.vhd" | sort-object LastWriteTime | Select-Object -ExpandProperty LastWriteTime

     

    The 'ExpandProperty' parameter is supposed to be used for expanding properties that are collections, but if the property is a scalar value it will just print it out without the header. Odd, but works.

    A more direct way is:


    get-childitem "*.vhd" | sort-object LastWriteTime | ForEach-Object {$_.LastWriteTime}

    • Proposed as answer by MOW_ Wednesday, July 21, 2010 11:23 PM
    • Marked as answer by Mervyn Zhang Thursday, July 22, 2010 5:14 AM
    Wednesday, July 21, 2010 11:18 PM
  • Either of those still produce a blank output line at the beginning.
     
    I have to do this
     
       get-childitem *.vhd | sort-object LastWriteTime |
          ForEach-Object {$_.LastWriteTime} | Out-String -stream |
             select-object -skip 1

    to keep that extra beginning blank line from appearing in the output.
     

    • Marked as answer by Mervyn Zhang Friday, July 23, 2010 5:16 AM
    Thursday, July 22, 2010 1:42 AM
  • You can try 

    Select-Object -ExpandProperty LastWriteTime | ft -hidetableheaders

    • Proposed as answer by Meat77 Friday, March 14, 2014 4:16 PM
    Saturday, January 25, 2014 2:00 AM
  • Thank you, worked with option "ft -hidetableheaders".
    • Proposed as answer by KimITdude Friday, October 26, 2018 11:53 AM
    Wednesday, September 20, 2017 12:08 PM
  • My problem was trying to pull the ONLY line of import out of Measure-Object output. I hit 2 issues:

    1. You can't directly use the object from measure-object as a string. This is a problem when you're trying to count something over time.
    2. When converted to a string, the output has junk lines at both the beginning (the header and blank lines) and the end (blanks at the end)

    This is what I came up with as brute force:

      $result = tasklist | findstr server | measure-object -line | Out-String -stream | select-object -skip 3 | select-object -first 1

    Tuesday, August 27, 2019 3:08 PM