echo All drives mapped successfully. pause
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
net use Z: \\Server01\Projects /user:DOMAIN\john.doe P@ssw0rd123 Persistent vs. Temporary Mappings By default, mapped drives are persistent —they reconnect automatically after you log off and back on. To create a temporary mapping that disappears when you log off, use:
$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.
net use Z: \\Server01\Projects /user:CONTOSO\jsmith * Listing Current Connections To see all active network drives and connections:
net use /verbose To remove a specific mapped drive: