Why "where" condition does not result correct?

Welcome Forums General PowerShell Q&A Why "where" condition does not result correct?

This topic contains 2 replies, has 2 voices, and was last updated by

 
Participant
5 years, 7 months ago.

  • Author
    Posts
  • #9622

    Participant
    Points: 0
    Rank: Member

    Hi, I have a files lines of file names, like:

    file1.txt
    File2.txt
    FILE3.txt
    FILE4.TXT

    I run a commnad below:

    cat \\share\file.txt | where { $_.ToUpper().Split(".")[0] -ne $_.Split(".")[0] }

    But, it does not result with expected result, that is:

    file1.txt
    File2.txt

    Why? Can someone help me?

    Regards

  • #9623

    Keymaster
    Points: 1,811
    Helping HandTeam Member
    Rank: Community Hero

    PowerShell is case-insensitive on string comparisons. Use -cne instead of -ne.

  • #9624

    Participant
    Points: 0
    Rank: Member

    Hi Don,

    Thank you so much, it works very nice.

    Regards

The topic ‘Why "where" condition does not result correct?’ is closed to new replies.

denizli escort samsun escort muğla escort ataşehir escort kuşadası escort