The user has appropriate permissions to read the share, and the share maps properly. This issue seems to happen only in PowerShell v2.0.
If I remove all mapped drives, remap one drive, and run Test-Path:
net use /delete * /y
net use G: \\somefileserver\share
Test-Path G:\
Test-Path returns False, even though the drive is clearly mapped, and I can access it through Windows Explorer.
If I close the PowerShell session, and open a new session, Test-Path returns True, as it should. Any ideas on, (A): what could be causing this, and how do I make it work properly? or (B): Is there another way to test for the existence of a network drive besides Test-Path? I am attempting to write a logon script to map user's network drives and this behavior is driving me insane.
If the Test-Path
cmdlet is truly buggy, then I'd suggest using the Exists()
method on the System.IO.Directory
.NET class.
[System.IO.Directory]::Exists('G:\'); # This returns $true for me