
In Windows you can connect any SMB network shared folder located on a remote computer or server as a mapped drive. In this way, you connect a NAS network drive, or a USB flash drive connected to your home router. The mapped network folder is assigned a separate drive letter, which can be accessed through Explorer, file managers and all apps. You can map a network drive from the Windows GUI, cmd, or PowerShell.
How to Map a Network Drive in File Explorer?
To map a network folder from the Windows File Explorer, locate a shared folder, right-click on it and select “Map network drive”.
You need to specify the drive letter that you want to assign to the folder (Drive) and whether you need to reconnect the drive at the next login (Reconnect at sign-in).
Mapped drives are displayed in File Explorer and contain the path to the network shared folder in addition to the drive letter.
Using Net Use to Map Network Drive
If you know the full UNC path to the share network directory you want to mount as a separate drive, you can use the NET USE command.
NET USE general syntax:
net use <drive:> <path>
- Drive: – drive letter to be assigned to a shared folder;
- Path – UNC path to network folder.
All available parameters of the net use command can be displayed as:
Net use /?
NET USE
[devicename | *] [\\computername\sharename[\volume] [password | *]]
[/USER:[domainname\]username]
[/USER:[dotted domain name\]username]
[/USER:[username@dotted domain name]
[/SMARTCARD]
[/SAVECRED]
[/REQUIREINTEGRITY]
[/REQUIREPRIVACY]
[[/DELETE] | [/PERSISTENT:{YES | NO}]]
To connect the \\lon-fs01\docs\sales folder and assign a drive letter U, run the command:
net use U: \\lon-fs01\docs\sales
If you need to authenticate to access the shared folder, a window will appear in which you need to prompt your credentials to access. If you don’t want to input credentials on every access, you can specify the user name and password using the command:
net use U: \\lon-fs01\docs\sales /user:your_user_name Your_P@ssw0rd
By default, the connected drive is not permanent and disappears when the computer is restarted. If you want to automatically map a drive the next time the user logs in, you need to use the /persistent:yes option.
The complete command for connecting a permanent disk looks like this:
net use U: \\lon-fs01\docs\sales /user:your_user_name Your_P@ssw0rd /persistent:yes
If there are several users on the computer, you can automatically map a shared folder to all users at login. To do this, create a text file map_drive.bat with the following code:
net use Z: /delete net use Z: “\\PC1\docs\sales" /user:PC1\pc1_user_name P@ssw0rdd
Where:
- PC1 – the name of the remote computer where the network folder is stored;
- pc1_user_name – the local user on a PC1 with a permissions to access folder.
It remains to copy your bat file to the directory C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup. As a result, this script will run at of each user login and map a network drive.
To unmap a network drive, use the parameter /delete.
To disconnect a previously connected mapped drive U:, use the command:
net use U: /delete
To remove all mapped drives, specify *.
net use * /delete
Network Drive Mapping with PowerShell
You can also manage mapped drives with PowerShell (PowerShell version 3.0 or newer).
To permanently map a drive using PowerShell under the a_smith account, run the command.
New-PSDrive -Name Z -PSProvider FileSystem -Root “\\lon-fs01\docs\sales” -Credential theitbros\a_smith –Persist
This will open a window in which you need to specify the password of the specified account to access the network folder.
To display a list of mapped network drives, use the command:
Get-PSDrive -PSProvider FileSystem | Select-Object Name, DisplayRoot | Where-Object {$_.DisplayRoot -ne $null}
In PowerShell 5.0+, you can use another cmdlet—New-SmbMapping:
New-SmbMapping -LocalPath Z -RemotePath “\\lon-fs01\docs\sales” -Persistent:$true
In this article, we looked at how to use mapped network drives in Windows 10 using NET USE and PowerShell.
The post How to Map a Network Drive in Windows 10? appeared first on TheITBros.