Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to set location to mapped network drive Z in PowerShell and it's not working.

I have the following drive letters: C, D, E, Z. Where the first three are just local disks, and the Z is of course the network location mapped to the letter Z.

I can switch from C to D, to E, back to C again, but I cannot for the love of God switch to Z letter for some reason. I can however switch to that location, but I have to type in the network location instead of using the drive letter.

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

PS C:\Windows\system32> Set-Location \\fileserver\karta
PS Microsoft.PowerShell.Core\FileSystem::\\fileserver\karta> C:
PS C:\Windows\system32> Z:
Set-Location : Cannot find drive. A drive with the name 'Z' does not exist.
At line:1 char:13
+ Set-Location <<<<  Z:
    + CategoryInfo          : ObjectNotFound: (Z:String) [Set-Location], DriveNotFoundException
    + FullyQualifiedErrorId : DriveNotFound,Microsoft.PowerShell.Commands.SetLocationCommand

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

PS C:\Windows\system32>

a

Why is it not working? Is this not supported in PowerShell... using drive letters to set location to a network location?

share|improve this question
    
Just for the record I am running x86 version of PowerShell with admin elevation on x64 Windows 7. – sammyg Apr 7 '14 at 13:36
    
That is very odd, I can't seem to replicate the issue. Does it work without admin elevation? – Alex McKenzie Apr 7 '14 at 13:58
    
@AlexMcKenzie Yup! It worked without admin elevation!? So what's the issue then?... – sammyg Apr 7 '14 at 14:11

The problem you're running into is because the Z: drive is mapped in your user's context, but not in the "administrator" context.

So when you run PowerShell "As Administrator" the Z: drive (map) doesn't exist and if you want it, you'd have to create it in that context for it to be available.

share|improve this answer
    
This is exactly the problem I was running into... I mapped my network drives in a non-elevated PS session, and tried accessing them from an elevated session. If you re-map your network drives in an elevated context, you should be good! – qJake Aug 18 '14 at 14:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .