none
How to map a network drive remotely RRS feed

  • Question

  • I have tried to map a network drive through powershell script, but it is visible for that id only after log off and login back. Anyway to remotely map a network drive when the user is logged in.

    I had followed the below command.

    PS C:\Users\Administrator> Invoke-Command -ComputerName computer01 -Credential contoso\test1 -ScriptBlock {net use i: \\Share\Scripts /user:contoso\Test1 password }

    The command completed successfully.

    But when in the machine i am getting status us unavailable. 

    Before logoff and login:

    Status       Local     Remote                    Network

    -------------------------------------------------------------------------------
    Unavailable  I:        \\Share\Scripts     Microsoft Windows Network
    The command completed successfully.

    After logoff and login:

    Status       Local     Remote                    Network

    -------------------------------------------------------------------------------
    OK           I:        \\Share\Scripts     Microsoft Windows Network
    The command completed successfully.

    Any solution to this without log off  or any other way to map a Network drive on the remote machine without log off and login.. Please suggest.

    Thanks in advance.

    Thursday, March 16, 2017 12:51 PM

Answers

  • Thanks Teemo Tang.

    Actually My issue is different. I am trying to write a script to give access to the endusers whoever wants to map a new network drive into their endpoint. There will be lakhs of users.

    I just found a alternative way to achieve this.

     Instead of log off/login we can kill and start windows explorer.exe which indirectly refreshes the user profile. 

    1.) First map the windows share through powershell script by the below script on the remote machine

    PS C:\Users\Administrator> Invoke-Command -ComputerName test01 -Credential itislab\testuser -ScriptBlock {net use i:  \\share\share01 /y /user:itislab\testuser password /Persistent; }

    once this step is over we can find that the network drive is mapped but status is unavailable.

    2.) Once this is done, Kill the windows explorer process in the target computer and relaunch the windows explorer process.

             Otherwise run the powershell command Stop-Process -ProcessName explorer

    It will automatically relaunch explorer.exe which indirectly refreshes the user session.

    Thus without a restart/logoff/login we can map a share drive into the end user machine.

    • Marked as answer by Bose Ganesan Friday, March 17, 2017 6:58 AM
    Friday, March 17, 2017 6:58 AM

All replies

  • Hi Bose Ganesan,

    Try to download Remote Desktop Connection Manager 2.7 and use it to manage your remote connection. When you remote target computer via this tool, access to network share folder by IP address and map drive directly.(right-click share folder and select Map network drive…)

    https://www.microsoft.com/en-sg/download/details.aspx?id=44989

    On the other hand, you could use Net use command-line to map network drive.

    net use * \\remotepc\share /u:domainname\username password

    for more information please refer to this link.

    https://technet.microsoft.com/en-us/library/bb490717.aspx?f=255&MSPPError=-2147217396

    Regards



    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    Friday, March 17, 2017 6:38 AM
    Moderator
  • Thanks Teemo Tang.

    Actually My issue is different. I am trying to write a script to give access to the endusers whoever wants to map a new network drive into their endpoint. There will be lakhs of users.

    I just found a alternative way to achieve this.

     Instead of log off/login we can kill and start windows explorer.exe which indirectly refreshes the user profile. 

    1.) First map the windows share through powershell script by the below script on the remote machine

    PS C:\Users\Administrator> Invoke-Command -ComputerName test01 -Credential itislab\testuser -ScriptBlock {net use i:  \\share\share01 /y /user:itislab\testuser password /Persistent; }

    once this step is over we can find that the network drive is mapped but status is unavailable.

    2.) Once this is done, Kill the windows explorer process in the target computer and relaunch the windows explorer process.

             Otherwise run the powershell command Stop-Process -ProcessName explorer

    It will automatically relaunch explorer.exe which indirectly refreshes the user session.

    Thus without a restart/logoff/login we can map a share drive into the end user machine.

    • Marked as answer by Bose Ganesan Friday, March 17, 2017 6:58 AM
    Friday, March 17, 2017 6:58 AM
  • Very well, thanks for your updating and sharing.

    Hope your experience will help other forum users who meet with same situation.

    You are welcome, I am glad to assist you with problem.

    Regards


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    Friday, March 17, 2017 7:16 AM
    Moderator