Map Drive From Command Line May 2026

net use Z: \\server\share /user:DOMAIN\username * The asterisk ( * ) tells Windows to prompt for a password without echoing it to the screen. For fully automated scripts (use with caution), you can include the password directly:

Next time you need to map a drive, don’t open File Explorer. Open Command Prompt or PowerShell—and feel the difference. map drive from command line

net use Z: \\server\share This maps the share \\server\share to drive letter Z: . If the share requires authentication, net use will prompt you for a username and password. But you can supply them inline for automation: net use Z: \\server\share This maps the share

| Task | Command | |------|---------| | Map persistent drive | net use Z: \\server\share /persistent:yes | | Map with specific credentials | net use Z: \\server\share /user:DOMAIN\user * | | Delete mapping | net use Z: /delete | | Delete all mappings | net use * /delete | | PowerShell persistent drive | New-PSDrive -Name Z -PSProvider FileSystem -Root \\server\share -Persist | | View all connections | net use | PowerShell uniquely allows mapping a network share to

$cred = Get-Credential New-PSDrive -Name "Z" -PSProvider FileSystem -Root "\\server\share" -Credential $cred -Persist The Get-Credential dialog is secure, but for automation you can build a credential object (though storing passwords in scripts is still discouraged). PowerShell uniquely allows mapping a network share to a local folder path instead of a drive letter—something net use cannot do directly: