Test-Path Question

Welcome Forums General PowerShell Q&A Test-Path Question

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

 
Participant
3 years, 6 months ago.

  • Author
    Posts
  • #24231

    Participant
    Points: 0
    Rank: Member

    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

    Participant
    Points: 0
    Rank: Member

    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

    Participant
    Points: 0
    Rank: Member

    That's was great!! Thanks

The topic ‘Test-Path Question’ is closed to new replies.