net use Z: \\Server01\Projects /user:CONTOSO\jsmith * Listing Current Connections To see all active network drives and connections:
net use * /delete You will be prompted: You have these remote connections: ... Continue with operation? (Y/N) . To suppress the prompt, pipe Y or use echo :
net use Z: "\\Server01\Project Files\Q1 Reports" You can explicitly specify the domain and even the domain controller: cmd command to map network drive
net use Z: /delete Always confirm by running net use again to ensure it is gone. To wipe all current network connections in one command (useful for login scripts to start fresh):
@echo off echo Mapping network drives for user %username%... :: Delete existing connections to start clean net use * /delete /yes To suppress the prompt, pipe Y or use
For more verbose information including credential details:
$cred = Get-Credential New-PSDrive -Name "Z" -PSProvider FileSystem -Root "\\Server01\Projects" -Credential $cred -Persist Mapping network drives via the command line using net use is a powerful, flexible, and reliable method that every Windows professional should master. From quick one-off mappings to complex automated login scripts, the command line gives you control that the GUI simply cannot match. From quick one-off mappings to complex automated login
net use [devicename | *] [\\computername\sharename[\volume] [password | *]] [/user:[domainname\]username] [/persistent:yes ] Let's break down the key parameters: