Test-Path Question

This topic contains 2 replies, has 2 voices, and was last updated by Profile photo of Kawika Moss Kawika Moss 2 years, 1 month ago.

  • Author
    Posts
  • #24231
    Profile photo of Kawika Moss
    Kawika Moss
    Participant

    I'm attempting to test the Test-Path cmdlet on a path that I already know exists, as such:

    Test-Path "\\server1\engineering_store\H11824\case2_Case_Files\Nuix\simpleCases\H11824_2\InUse"

    And it keeps returning false...Why?

    Thanks

  • #24237
    Profile photo of Simon Wåhlin
    Simon Wåhlin
    Participant

    If you currently are in a location that is not using the filesystem drive, testing UNC-paths fails. To work around this, either use Set-Location -Path $Env:SystemDrive first or prepend filesystem:: to your path to tell test-path which psprovider to use, like this:

    Test-Path -Path "filesystem::\\server1\engineering_store"

  • #24263
    Profile photo of Kawika Moss
    Kawika Moss
    Participant

    That's was great!! Thanks

You must be logged in to reply to this topic.