Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Set-Location : Cannot find drive. A drive with the name 'P' does not exist.

$
0
0

Hello All,

I have a strange Problem with network drives I am mapping and using in Powershell. If I map a network drive the first time I could set-location and able to browse thought the drive. If I dissconect the drive and re-create the drive again, I am not able to set-location and browse to the drive anymore...

$PDrive = "\\ShareName\Projects$\P1757_xxx"
(new-object -com WScript.Network).MapNetworkDrive("P:",$PDrive)
Set-Location P: WORKING :-)
Set-Location C:
(new-object -com WScript.Network).RemoveNetworkDrive("P:")

$PDrive = "\\ShareName\Projects$\P1757_xxx"
(new-object -com WScript.Network).MapNetworkDrive("P:",$PDrive)
Set-Location P: NOT WORKING :-(

Set-Location : Cannot find drive. A drive with the name 'P' does not exist.
At line:1 char:13
+ Set-Location <<<<  P:
    + CategoryInfo          : ObjectNotFound: (P:String) [Set-Location], DriveNotFoundException
    + FullyQualifiedErrorId : DriveNotFound,Microsoft.PowerShell.Commands.SetLocationCommand

Share is showing up in PsDrive and on net use, but I Am Not able to use it thought PowerShell. Same Problem if I Map and Remove the NetworkDrive with net use... In CMD the Network Drive is accessiable after Recreation?????


Viewing all articles
Browse latest Browse all 21975

Trending Articles