query regarding compare-object output

  • Hello ,
    Can anybody help me with below :

    compare-object (get-content file1.txt) (get-content file.txt)
    | where { $_.SideIndicator -eq '<='}

    InputObject          SideIndicator
    -----------          -------------
    02-06-2019          <=
    02-07-2019          <=
    02-09-2019          <=
    02-10-2019          <=

    Is there any way print only 1st column with different name  like

    Expected output :

    Date         
    -----------         
    02-06-2019          
    02-07-2019          
    02-09-2019          
    02-10-2019

  • I guess my question would be, why aren't you using T-SQL to do this?

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • No Sir..Because I am fetching file1.txt details from another server.

  • A simple google search would have found the answer, add the following to end of your code

    | select-object -Property InputObject

    Far away is close at hand in the images of elsewhere.
    Anon.

  • Namrish - Thursday, March 7, 2019 7:40 AM

    No Sir..Because I am fetching file1.txt details from another server.

    That doesn't mean that you have to go outside of T-SQL to do this but, whatever.  It would seem that Mr. Burrows has found an answer for you.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply