Windows - Map a network drive (net use persistent)

Using the GUI

  1. Select the Windows Start Icon > Computer.
  2. In the top menu of Windows Explorer, select Map network drive.
  3. In the Map Network Drive dialog box, type \\\share and select Finish.  Replace with the domain name or IP address of the share.

Using the command line

  1. Type net use and press enter to view the available drives that can be mapped
  2. Type net use <drive letter>: <UNC path> and press enter (example: net use m: \\\share)
    • Note: the /delete option can be used to disconnect a mapped network drive (example: net use m: /delete)

Using PowerShell


# Add a network drive
$pass="Your Password"|ConvertTo-SecureString -AsPlainText -Force
$Cred = New-Object System.Management.Automation.PsCredential('Your Username',$pass)
New-PSDrive -Name X -PSProvider FileSystem -Root \\\share -Credential $Cred -Persist

# List the network drives

# Remove the network drives
Remove-PSDrive -Name X -PSProvider FileSystem


net use

$FS2 = "\\\share"
$username = "Your Username"
$password = "Your Password"

net use $FS2 $password /USER:$username  

On Boot

To have a network drive mapped when Windows is restarted, you can create a batch file, such as map.bat at C:\Users\your_username\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup, and the network drive will be mapped on boot.

net use z: \\\share /persistent:yes


Username / Password

When mapping the network drive, there may be a prompt to enter a username and password.


If the Samba is being used for the share, on the Samba server, use the smbpasswd command to add a users password to the SMB database. You can now connect to the Samba share using the username and password.

[root@server1 ~]# smbpasswd -a jeremy
New SMB password: ********
Retype new SMB password: ********



Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee

Add a Comment

We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.

Please enter 00187 in the box below so that we can be sure you are a human.


Web design by yours truely - me, myself, and I   |   |