AnswerBun.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!

Related Questions

Port not responding remotely, but shows as open locally

1  Asked on November 12, 2021 by avjinder-sekhon

       

nginx error 500 when making api request to backend container

0  Asked on November 12, 2021 by christian-geng

         

Understanding smartd

1  Asked on November 12, 2021 by dovid-bender

     

mdadm alerts configuration

0  Asked on November 12, 2021 by mindserver

   

Cannot restart apache after certificate replacement

1  Asked on November 12, 2021 by kyle-banerjee

   

Reverse proxying a HLS stream with nginx

0  Asked on November 12, 2021 by mayleap1

         

Varnish PURGE client.ip docker-compose

1  Asked on November 12, 2021 by zhartaunik

   

Nginx refuses custom error pages

1  Asked on November 12, 2021

       

splitting tcp traffic to multiple recipients on the backend?

1  Asked on November 12, 2021 by kevin-martin

       

Curl – download file range

2  Asked on November 10, 2021

 

apache times out with low cpu and memory usage

1  Asked on November 10, 2021 by develth

     

MySQL Cluster SQL Node not synchronizing

1  Asked on November 10, 2021 by user2249803

   

nginx: different configuration based on cookie

2  Asked on November 10, 2021 by jay-paroline

 

How to connect to Windows Nano Server via SSH?

2  Asked on November 10, 2021 by andre-figueiredo

     

Redirect to localhost:8080?

3  Asked on November 10, 2021 by meds

     

Ask a Question

Get help from others!

© 2022 AnswerBun.com. All rights reserved. Sites we Love: PCI Database, MenuIva, UKBizDB, Menu Kuliner, Sharing RPP, SolveDir