TransWikia.com

Powershell / Command prompt cannot switch to mapped drive when running as another use

Server Fault Asked by SEarle1986 on November 28, 2020

in my powershell prompt, logged into a Windows 10 PC as DomainUserA i can run the net use command to see my shared drives

net use

lists

+--------+-------+----------------+---------------------------+
| Status | local |     Remote     |          Network          |
+--------+-------+----------------+---------------------------+
| OK     | H:    | \server1path | Microsoft Windows Network |
| OK     | I:    | \server2path | Microsoft Windows Network |
+--------+-------+----------------+---------------------------+

i can then run

i:

and the prompt switches to I:>

however, If I run the powershell prompt as DomainUserB and run the net use comand

I get

+-------------+-------+----------------+---------------------------+
|   Status    | local |     Remote     |          Network          |
+-------------+-------+----------------+---------------------------+
| Unavailable | H:    | \server1path | Microsoft Windows Network |
| Unavailable | I:    | \server2path | Microsoft Windows Network |
| Unavailable | Z:    | \server3path | Microsoft Windows Network |
+-------------+-------+----------------+---------------------------+

as this profile has the same H: and I: drive as the first one but also a z: drive.

if i then run

I:

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

I can perform the same process in command prompt and i get the same result , although with command prompt’s version of the error: The system cannot find the drive specified

If I run a GUI based program such as notepad as DomainUserB and do a File>Open, I can see the i: drive in the explorer pane and open it and select a file

This happens with all of the mapped drives

why can i not change directory to the mapped drive using when running Powershell / command prompt as the DomainuserB

2 Answers

Running as another user always requires the process to be elevated into admin mode, which hides the user mode mapped drives from the process.

Run PowerShell as User B, then map the drive, and you should be able to access it.

If you were not in an elevated state you could re-use the drive mapping User B already has, but you would need to sign in as User B.

Answered by Garrett on November 28, 2020

@Lee_Dailey has said right.

normally, a mapped drive is account specific. so one that i make as UserA will not be seen by UserB. plus, maps done while elevated ["as admin"] will not be seen by the same account when NOT elevated. ///// the behavior you describe is what i expect.

So you need map the drive system-wide. For this, first you will need to psexec tool by Sysinternals.

  • Run psexec -s -i powershell (Puts you on a Powershell session as SYSTEM user)
  • Then map the drives you need

Now mapped drives will show on system-wide

Answered by Wasif Hasan on November 28, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP