Unexplained case sensitivity with Test-Path

Welcome Forums General PowerShell Q&A Unexplained case sensitivity with Test-Path

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

 
Keymaster
1 year, 8 months ago.

  • Author
    Posts
  • #66859

    Participant
    Points: 1
    Rank: Member

    Hi,

    I was surprised to find, when doing a Test-Path check on UNC paths, that the result PowerShell gave was case-sensitive. The paths I'm testing are on a Nexenta storage device. Does the type of device or some response from the device affect the results of Test-Path?

    Thanks,
    Joel

  • #66862

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

    Yeah. The command just asks the file system if the path exists. If the file system cares about case, then it acts accordingly. Most *nix file systems are case sensitive.

    • #66868

      Participant
      Points: 1
      Rank: Member

      Thanks, Don. Good to know, though even better to know would be how to identify if the file system a path uses is *nix or not. I don't see that Get-Item returns anything that would shed light on this.

  • #66871

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

    The file systems actually have no interface for revealing that. And it's more nuanced because, for example, some Linux SMB layers abstract it and remove case sensitivity.

    You could easily write a simple test tho. Just test for a known existing path using lowercase and uppercase. If both return true then it isn't sensitive. If only one returns true then it is.

The topic ‘Unexplained case sensitivity with Test-Path’ is closed to new replies.