none
cannot read UNC path with PS script RRS feed

  • Question

  • You cannot vote on your own post                  

    I have an issue reading a UNC path via PS script unless I browse to path in windows explorer before running script.

    $path = "\\sharepoint.xxxxx.com\xx\xx\xx\new hire test"

    $testpath = test-path -path $path

    if ($testpath -eq $true)

    {

           call function

    }

    else

    {

    write-host "Fail: Connection to SharePoint site could not be made."

    }

    This errors out each time stating that the path does not exist but as soon as I browse to the path in Windows Explorer and run the script again all is well. I hoping someone else has seen this behavior and not just me.


    Corey Radford | IT Client Services Dixon Hughes Goodman LLP D 704.367.7049 T 704.367.7020 6525 Morrison Boulevard, Suite 500, Charlotte, NC 28211 Corey.Radford@dhgllp.com

    Tuesday, April 16, 2013 6:05 PM

Answers

  • in one of my powershell script that includes WPF GUI (using xaml file), I experience the same behavior. If I map a network drive using "wscript.network COM object", "test-path" cmdlet always returns false to the mapped drive or UNC path.

    I had to use [System.IO.Directory]::Exists($mapDrive), that works correctly.


    cheers..uc

    • Marked as answer by IamMred Wednesday, May 1, 2013 3:32 AM
    Wednesday, April 17, 2013 8:02 AM

All replies

  • Not a scripting issue.

    Call your support people to check your configuration.  It appears you are not authenticating somewhere.


    ¯\_(ツ)_/¯

    • Proposed as answer by jrv Wednesday, April 17, 2013 3:18 PM
    Tuesday, April 16, 2013 6:23 PM
  • Not sure I trust our SP admin but I was able to use New-PSDrive to do what I needed.
    Tuesday, April 16, 2013 6:57 PM
  • in one of my powershell script that includes WPF GUI (using xaml file), I experience the same behavior. If I map a network drive using "wscript.network COM object", "test-path" cmdlet always returns false to the mapped drive or UNC path.

    I had to use [System.IO.Directory]::Exists($mapDrive), that works correctly.


    cheers..uc

    • Marked as answer by IamMred Wednesday, May 1, 2013 3:32 AM
    Wednesday, April 17, 2013 8:02 AM